- @Test
- public void postOperationsStatusCodes() throws IOException {
- controllerContext.setSchemas(schemaContextTestModule);
- mockInvokeRpc(cnSnDataOutput, true);
- String uri = "/operations/test-module:rpc-test";
- assertEquals(200, post(uri, MediaType.APPLICATION_XML, xmlDataRpcInput));
-
- mockInvokeRpc(null, true);
- assertEquals(204, post(uri, MediaType.APPLICATION_XML, xmlDataRpcInput));
-
- mockInvokeRpc(null, false);
- assertEquals(500, post(uri, MediaType.APPLICATION_XML, xmlDataRpcInput));
-
- List<RpcError> rpcErrors = new ArrayList<>();
- rpcErrors.add(RpcResultBuilder.newError(ErrorType.RPC, "tag1", "message1", "applicationTag1", "info1", null));
- rpcErrors.add(RpcResultBuilder.newWarning(ErrorType.PROTOCOL, "tag2", "message2", "applicationTag2", "info2",
- null));
- mockInvokeRpc(null, false, rpcErrors);
- assertEquals(500, post(uri, MediaType.APPLICATION_XML, xmlDataRpcInput));
-
- uri = "/operations/test-module:rpc-wrongtest";
- assertEquals(400, post(uri, MediaType.APPLICATION_XML, xmlDataRpcInput));
- }
-
- @Test
- public void postConfigOnlyStatusCodes() throws UnsupportedEncodingException {
- controllerContext.setSchemas(schemaContextYangsIetf);
- String uri = "/config";
- mockCommitConfigurationDataPostMethod(true);
- assertEquals(204, post(uri, MediaType.APPLICATION_XML, xmlDataAbsolutePath));
-
- mockCommitConfigurationDataPostMethod(false);
- assertEquals(500, post(uri, MediaType.APPLICATION_XML, xmlDataAbsolutePath));
-
- assertEquals(400, post(uri, MediaType.APPLICATION_XML, ""));
- }
-
- @Test
- public void postConfigStatusCodes() throws UnsupportedEncodingException {
- controllerContext.setSchemas(schemaContextYangsIetf);
- String uri = "/config/ietf-interfaces:interfaces";
-
- mockCommitConfigurationDataPostMethod(true);
- assertEquals(204, post(uri, MediaType.APPLICATION_XML, xmlDataInterfaceAbsolutePath));
-
- mockCommitConfigurationDataPostMethod(false);
- assertEquals(500, post(uri, MediaType.APPLICATION_XML, xmlDataInterfaceAbsolutePath));
-
- assertEquals(400, post(uri, MediaType.APPLICATION_JSON, ""));