private static UriInfo uriInfo;
private static SchemaContext schemaContext;
- private final RestconfImpl restconfImpl = RestconfImpl.getInstance();
+ private final RestconfImpl restconfImpl;
private final ControllerContext controllerContext;
+ private final BrokerFacade brokerFacade = mock(BrokerFacade.class);
public InvokeRpcMethodTest() {
controllerContext = TestRestconfUtils.newControllerContext(schemaContext);
- restconfImpl.setControllerContext(controllerContext);
+ restconfImpl = RestconfImpl.newInstance(brokerFacade, controllerContext);
}
@BeforeClass
assertTrue("Uri wasn't created sucessfuly", false);
}
- final BrokerFacade mockedBrokerFacade = mock(BrokerFacade.class);
-
- restconfImpl.setBroker(mockedBrokerFacade);
-
final NormalizedNodeContext payload = prepareDomPayload();
final NormalizedNodeContext rpcResponse =
final DOMRpcException exception = new DOMRpcImplementationNotAvailableException("testExeption");
final CheckedFuture<DOMRpcResult, DOMRpcException> future = Futures.immediateFailedCheckedFuture(exception);
- final BrokerFacade brokerFacade = mock(BrokerFacade.class);
-
final QName qname = QName.create("(http://netconfcentral.org/ns/toaster?revision=2009-11-20)cancel-toast");
final SchemaPath type = SchemaPath.create(true, qname);
when(brokerFacade.invokeRpc(eq(type), any(NormalizedNode.class))).thenReturn(future);
- this.restconfImpl.setBroker(brokerFacade);
-
try {
this.restconfImpl.invokeRpc("toaster:cancel-toast", "", uriInfo);
fail("Expected an exception to be thrown.");
} catch (final RestconfDocumentedException e) {
verifyRestconfDocumentedException(e, 0, ErrorType.APPLICATION, ErrorTag.OPERATION_NOT_SUPPORTED,
- Optional.<String>absent(), Optional.<String>absent());
+ Optional.absent(), Optional.absent());
}
}
final SchemaPath path = SchemaPath.create(true,
QName.create("(http://netconfcentral.org/ns/toaster?revision=2009-11-20)cancel-toast"));
- final BrokerFacade brokerFacade = mock(BrokerFacade.class);
when(brokerFacade.invokeRpc(eq(path), any(NormalizedNode.class))).thenReturn(future);
- this.restconfImpl.setBroker(brokerFacade);
-
try {
this.restconfImpl.invokeRpc("toaster:cancel-toast", "", uriInfo);
fail("Expected an exception to be thrown.");
} catch (final RestconfDocumentedException e) {
verifyRestconfDocumentedException(e, 0, ErrorType.TRANSPORT, ErrorTag.OPERATION_FAILED, Optional.of("foo"),
- Optional.<String>absent());
+ Optional.absent());
verifyRestconfDocumentedException(e, 1, ErrorType.RPC, ErrorTag.IN_USE, Optional.of("bar"),
Optional.of("app-tag"));
}
final QName qname = QName.create("(http://netconfcentral.org/ns/toaster?revision=2009-11-20)cancel-toast");
final SchemaPath path = SchemaPath.create(true, qname);
- final BrokerFacade brokerFacade = mock(BrokerFacade.class);
when(brokerFacade.invokeRpc(eq(path), any(NormalizedNode.class))).thenReturn(future);
- this.restconfImpl.setBroker(brokerFacade);
-
final NormalizedNodeContext output = this.restconfImpl.invokeRpc("toaster:cancel-toast", "", uriInfo);
assertNotNull(output);
assertEquals(null, output.getData());
fail("Expected an exception");
} catch (final RestconfDocumentedException e) {
verifyRestconfDocumentedException(e, 0, ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE,
- Optional.<String>absent(), Optional.<String>absent());
+ Optional.absent(), Optional.absent());
}
}
fail("Expected an exception");
} catch (final RestconfDocumentedException e) {
verifyRestconfDocumentedException(e, 0, ErrorType.RPC, ErrorTag.UNKNOWN_ELEMENT,
- Optional.<String>absent(), Optional.<String>absent());
+ Optional.absent(), Optional.absent());
}
}
new NormalizedNodeContext(new InstanceIdentifierContext<>(null, rpcInputSchemaNode,
null, schemaContext), containerBuilder.build());
- final BrokerFacade brokerFacade = mock(BrokerFacade.class);
when(brokerFacade.invokeRpc(eq(path), any(NormalizedNode.class))).thenReturn(future);
- this.restconfImpl.setBroker(brokerFacade);
final NormalizedNodeContext output = this.restconfImpl.invokeRpc("toaster:make-toast", payload, uriInfo);
assertNotNull(output);
fail("Expected an exception.");
} catch (final RestconfDocumentedException e) {
verifyRestconfDocumentedException(e, 0, ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE,
- Optional.<String>absent(), Optional.<String>absent());
+ Optional.absent(), Optional.absent());
}
}
final DOMRpcResult result = new DefaultDOMRpcResult(container);
final CheckedFuture<DOMRpcResult, DOMRpcException> future = Futures.immediateCheckedFuture(result);
- final BrokerFacade brokerFacade = mock(BrokerFacade.class);
when(brokerFacade.invokeRpc(eq(rpcDef.getPath()), any(NormalizedNode.class))).thenReturn(future);
- this.restconfImpl.setBroker(brokerFacade);
-
final NormalizedNodeContext output = this.restconfImpl.invokeRpc("toaster:testOutput", "", uriInfo);
assertNotNull(output);
assertNotNull(output.getData());