summaryrefslogtreecommitdiffstats
path: root/src/test/java/org/onap
diff options
context:
space:
mode:
authored852m <ed.dening@amdocs.com>2019-03-14 11:18:48 +0000
committered852m <ed.dening@amdocs.com>2019-03-14 13:33:43 +0000
commitf1dc7620477e26db40a91c43ded1dbfa8fe3ccc0 (patch)
tree5cfdad346a9c6bb828e6e5b301327e253a73cf51 /src/test/java/org/onap
parenta7580c5ec0fa9147c11966aece6cd5b8ad0b4f77 (diff)
Handle unexpected HTTP return codes
Issue-ID: AAI-2263 Change-Id: I2510b7a2630918ffe17efbbf813c3e43b0b44d34 Signed-off-by: ed852m <ed.dening@amdocs.com>
Diffstat (limited to 'src/test/java/org/onap')
-rw-r--r--src/test/java/org/onap/aai/modelloader/entity/model/TestModelArtifactHandler.java45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/test/java/org/onap/aai/modelloader/entity/model/TestModelArtifactHandler.java b/src/test/java/org/onap/aai/modelloader/entity/model/TestModelArtifactHandler.java
index 2a951a8..b7a8cf2 100644
--- a/src/test/java/org/onap/aai/modelloader/entity/model/TestModelArtifactHandler.java
+++ b/src/test/java/org/onap/aai/modelloader/entity/model/TestModelArtifactHandler.java
@@ -120,5 +120,50 @@ public class TestModelArtifactHandler {
assertThat(pushed, is(true));
handler.rollback(artifacts, "", aaiClient);
}
+
+ @Test
+ public void testPushNewModelsBadRequest() {
+ when(config.getAaiBaseUrl()).thenReturn("");
+ when(config.getAaiModelUrl(any())).thenReturn("");
+ when(config.getAaiNamedQueryUrl(any())).thenReturn("");
+
+ OperationResult getResult = mock(OperationResult.class);
+ when(aaiClient.getResource(any(), any(), any())).thenReturn(getResult);
+ when(getResult.getResultCode()).thenReturn(Response.Status.NOT_FOUND.getStatusCode());
+
+ OperationResult putResult = mock(OperationResult.class);
+ when(aaiClient.putResource(any(), any(), any(), any())).thenReturn(putResult);
+ when(putResult.getResultCode()).thenReturn(Response.Status.BAD_REQUEST.getStatusCode());
+
+ checkRollback(Collections.singletonList(new ModelArtifact()));
+ }
+
+ @Test
+ public void testBadRequestResourceModelResult() {
+ when(config.getAaiBaseUrl()).thenReturn("");
+ when(config.getAaiModelUrl(any())).thenReturn("");
+
+ OperationResult operationResult = mock(OperationResult.class);
+ when(aaiClient.getResource(any(), any(), any())).thenReturn(operationResult);
+ when(operationResult.getResultCode()).thenReturn(Response.Status.BAD_REQUEST.getStatusCode());
+
+ checkRollback(Collections.singletonList(new ModelArtifact()));
+ }
+
+ @Test
+ public void testNullResourceModelResult() {
+ when(config.getAaiBaseUrl()).thenReturn("");
+ when(config.getAaiModelUrl(any())).thenReturn("");
+ when(aaiClient.getResource(any(), any(), any())).thenReturn(null);
+
+ checkRollback(Collections.singletonList(new ModelArtifact()));
+ }
+
+ private void checkRollback(List<Artifact> artifacts) {
+ ModelArtifactHandler handler = new ModelArtifactHandler(config);
+ boolean pushed = handler.pushArtifacts(artifacts, "", Collections.emptyList(), aaiClient);
+ assertThat(pushed, is(false));
+ handler.rollback(artifacts, "", aaiClient);
+ }
}