Code Review
/
controller.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Merge "Implement PortNumberBuilder"
[controller.git]
/
opendaylight
/
md-sal
/
sal-rest-connector
/
src
/
test
/
java
/
org
/
opendaylight
/
controller
/
sal
/
restconf
/
impl
/
test
/
InvokeRpcMethodTest.java
diff --git
a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/InvokeRpcMethodTest.java
b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/InvokeRpcMethodTest.java
index c0c86c3f25384fdbd3ea979debef62fa7f1512ab..b90097bc94a0e7888b589f33960343cc94d36c12 100644
(file)
--- a/
opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/InvokeRpcMethodTest.java
+++ b/
opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/InvokeRpcMethodTest.java
@@
-19,6
+19,9
@@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
import java.io.FileNotFoundException;
import java.net.URI;
import java.net.URISyntaxException;
import java.io.FileNotFoundException;
import java.net.URI;
import java.net.URISyntaxException;
@@
-27,7
+30,9
@@
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-
+import javax.ws.rs.core.MultivaluedHashMap;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.UriInfo;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
@@
-56,14
+61,11
@@
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
-
public class InvokeRpcMethodTest {
private RestconfImpl restconfImpl = null;
private static ControllerContext controllerContext = null;
public class InvokeRpcMethodTest {
private RestconfImpl restconfImpl = null;
private static ControllerContext controllerContext = null;
+ private static UriInfo uriInfo;
@BeforeClass
@BeforeClass
@@
-77,7
+79,10
@@
public class InvokeRpcMethodTest {
SchemaContext schemaContext = TestUtils.loadSchemaContext(allModules);
controllerContext = spy( ControllerContext.getInstance() );
controllerContext.setSchemas(schemaContext);
SchemaContext schemaContext = TestUtils.loadSchemaContext(allModules);
controllerContext = spy( ControllerContext.getInstance() );
controllerContext.setSchemas(schemaContext);
-
+ uriInfo = mock(UriInfo.class);
+ MultivaluedMap<String, String> map = new MultivaluedHashMap<>();
+ map.put("prettyPrint", Collections.singletonList("true"));
+ when(uriInfo.getQueryParameters(any(Boolean.class))).thenReturn(map);
}
@Before
}
@Before
@@
-114,7
+119,7
@@
public class InvokeRpcMethodTest {
.thenReturn( Futures.<RpcResult<CompositeNode>>immediateFuture(
Rpcs.<CompositeNode>getRpcResult( true ) ) );
.thenReturn( Futures.<RpcResult<CompositeNode>>immediateFuture(
Rpcs.<CompositeNode>getRpcResult( true ) ) );
- StructuredData structData = restconf.invokeRpc("invoke-rpc-module:rpc-test", payload);
+ StructuredData structData = restconf.invokeRpc("invoke-rpc-module:rpc-test", payload
,uriInfo
);
assertTrue(structData == null);
}
assertTrue(structData == null);
}
@@
-143,7
+148,7
@@
public class InvokeRpcMethodTest {
restconfImpl.setBroker(brokerFacade);
try {
restconfImpl.setBroker(brokerFacade);
try {
- restconfImpl.invokeRpc("toaster:cancel-toast", "");
+ restconfImpl.invokeRpc("toaster:cancel-toast", ""
,uriInfo
);
fail("Expected an exception to be thrown.");
}
catch (RestconfDocumentedException e) {
fail("Expected an exception to be thrown.");
}
catch (RestconfDocumentedException e) {
@@
-196,7
+201,7
@@
public class InvokeRpcMethodTest {
restconfImpl.setBroker(brokerFacade);
try {
restconfImpl.setBroker(brokerFacade);
try {
- restconfImpl.invokeRpc("toaster:cancel-toast", "");
+ restconfImpl.invokeRpc("toaster:cancel-toast", ""
,uriInfo
);
fail("Expected an exception to be thrown.");
}
catch (RestconfDocumentedException e) {
fail("Expected an exception to be thrown.");
}
catch (RestconfDocumentedException e) {
@@
-220,7
+225,7
@@
public class InvokeRpcMethodTest {
restconfImpl.setBroker(brokerFacade);
StructuredData output = restconfImpl.invokeRpc("toaster:cancel-toast",
restconfImpl.setBroker(brokerFacade);
StructuredData output = restconfImpl.invokeRpc("toaster:cancel-toast",
- "");
+ ""
,uriInfo
);
assertEquals(null, output);
//additional validation in the fact that the restconfImpl does not throw an exception.
}
assertEquals(null, output);
//additional validation in the fact that the restconfImpl does not throw an exception.
}
@@
-228,7
+233,7
@@
public class InvokeRpcMethodTest {
@Test
public void testInvokeRpcMethodExpectingNoPayloadButProvidePayload() {
try {
@Test
public void testInvokeRpcMethodExpectingNoPayloadButProvidePayload() {
try {
- restconfImpl.invokeRpc("toaster:cancel-toast", " a payload ");
+ restconfImpl.invokeRpc("toaster:cancel-toast", " a payload "
,uriInfo
);
fail("Expected an exception");
} catch (RestconfDocumentedException e) {
verifyRestconfDocumentedException( e, 0, ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE,
fail("Expected an exception");
} catch (RestconfDocumentedException e) {
verifyRestconfDocumentedException( e, 0, ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE,
@@
-239,7
+244,7
@@
public class InvokeRpcMethodTest {
@Test
public void testInvokeRpcMethodWithBadMethodName() {
try {
@Test
public void testInvokeRpcMethodWithBadMethodName() {
try {
- restconfImpl.invokeRpc("toaster:bad-method", "");
+ restconfImpl.invokeRpc("toaster:bad-method", ""
,uriInfo
);
fail("Expected an exception");
}
catch (RestconfDocumentedException e) {
fail("Expected an exception");
}
catch (RestconfDocumentedException e) {
@@
-263,7
+268,7
@@
public class InvokeRpcMethodTest {
restconfImpl.setBroker(brokerFacade);
StructuredData output = restconfImpl.invokeRpc("toaster:make-toast",
restconfImpl.setBroker(brokerFacade);
StructuredData output = restconfImpl.invokeRpc("toaster:make-toast",
- payload);
+ payload
,uriInfo
);
assertEquals(null, output);
//additional validation in the fact that the restconfImpl does not throw an exception.
}
assertEquals(null, output);
//additional validation in the fact that the restconfImpl does not throw an exception.
}
@@
-271,7
+276,7
@@
public class InvokeRpcMethodTest {
@Test
public void testThrowExceptionWhenSlashInModuleName() {
try {
@Test
public void testThrowExceptionWhenSlashInModuleName() {
try {
- restconfImpl.invokeRpc("toaster/slash", "");
+ restconfImpl.invokeRpc("toaster/slash", ""
,uriInfo
);
fail("Expected an exception.");
}
catch (RestconfDocumentedException e) {
fail("Expected an exception.");
}
catch (RestconfDocumentedException e) {
@@
-294,7
+299,7
@@
public class InvokeRpcMethodTest {
restconfImpl.setBroker(brokerFacade);
restconfImpl.setBroker(brokerFacade);
- StructuredData output = restconfImpl.invokeRpc("toaster:testOutput", "");
+ StructuredData output = restconfImpl.invokeRpc("toaster:testOutput", ""
,uriInfo
);
assertNotNull( output );
assertSame( compositeNode, output.getData() );
assertNotNull( output.getSchema() );
assertNotNull( output );
assertSame( compositeNode, output.getData() );
assertNotNull( output.getSchema() );
@@
-308,7
+313,7
@@
public class InvokeRpcMethodTest {
ListenableFuture<RpcResult<CompositeNode>> mockListener = mock( ListenableFuture.class );
when( mockListener.get() ).thenReturn( rpcResult );
ListenableFuture<RpcResult<CompositeNode>> mockListener = mock( ListenableFuture.class );
when( mockListener.get() ).thenReturn( rpcResult );
- QName cancelToastQName = QName.create( "cancelToast" );
+ QName cancelToastQName = QName.create( "
namespace", "2014-05-28", "
cancelToast" );
RpcDefinition mockRpc = mock( RpcDefinition.class );
when( mockRpc.getQName() ).thenReturn( cancelToastQName );
RpcDefinition mockRpc = mock( RpcDefinition.class );
when( mockRpc.getQName() ).thenReturn( cancelToastQName );
@@
-330,7
+335,7
@@
public class InvokeRpcMethodTest {
restconfImpl.setControllerContext( mockedContext );
StructuredData output = restconfImpl.invokeRpc(
"opendaylight-inventory:nodes/node/REMOTE_HOST/yang-ext:mount/toaster:cancel-toast",
restconfImpl.setControllerContext( mockedContext );
StructuredData output = restconfImpl.invokeRpc(
"opendaylight-inventory:nodes/node/REMOTE_HOST/yang-ext:mount/toaster:cancel-toast",
- "");
+ ""
,uriInfo
);
assertEquals(null, output);
//additional validation in the fact that the restconfImpl does not throw an exception.
assertEquals(null, output);
//additional validation in the fact that the restconfImpl does not throw an exception.