From a9cdc79ba7e928b38ed132d38426b6c8b70635bf Mon Sep 17 00:00:00 2001 From: sebdet Date: Wed, 19 Sep 2018 18:35:11 +0200 Subject: Add tests Add some tests to cldsService Issue-ID: CLAMP-217 Change-Id: I95f21306f3d807a283519604c1711dfd07466d4a Signed-off-by: sebdet --- .../org/onap/clamp/clds/it/CldsServiceItCase.java | 33 ++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) (limited to 'src/test/java') diff --git a/src/test/java/org/onap/clamp/clds/it/CldsServiceItCase.java b/src/test/java/org/onap/clamp/clds/it/CldsServiceItCase.java index 3c508bd31..695aa2d15 100644 --- a/src/test/java/org/onap/clamp/clds/it/CldsServiceItCase.java +++ b/src/test/java/org/onap/clamp/clds/it/CldsServiceItCase.java @@ -50,6 +50,7 @@ import org.junit.runner.RunWith; import org.mockito.Matchers; import org.mockito.Mockito; import org.onap.clamp.clds.dao.CldsDao; +import org.onap.clamp.clds.model.CldsEvent; import org.onap.clamp.clds.model.CldsInfo; import org.onap.clamp.clds.model.CldsModel; import org.onap.clamp.clds.model.CldsServiceData; @@ -61,6 +62,8 @@ import org.skyscreamer.jsonassert.JSONAssert; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.core.Authentication; import org.springframework.security.core.GrantedAuthority; @@ -183,11 +186,37 @@ public class CldsServiceItCase { // Verify whether it has been added properly or not assertNotNull(cldsDao.getModel(randomNameModel)); + CldsModel model= cldsService.getModel(randomNameModel); // Verify with GetModel - assertEquals(cldsService.getModel(randomNameModel).getTemplateName(),randomNameTemplate); - assertEquals(cldsService.getModel(randomNameModel).getName(),randomNameModel); + assertEquals(model.getTemplateName(),randomNameTemplate); + assertEquals(model.getName(),randomNameModel); assertTrue(cldsService.getModelNames().size() >= 1); + + // Should fail + ResponseEntity responseEntity = cldsService.putModelAndProcessAction(CldsEvent.ACTION_SUBMIT, randomNameModel, "true", model); + assertTrue(responseEntity.getStatusCode().equals(HttpStatus.INTERNAL_SERVER_ERROR)); + model=(CldsModel)responseEntity.getBody(); + assertNull(model); + + responseEntity=cldsService.deployModel(randomNameModel, cldsService.getModel(randomNameModel)); + assertNotNull(responseEntity); + assertNotNull(responseEntity.getStatusCode()); + model=(CldsModel)responseEntity.getBody(); + assertNotNull(model); + + responseEntity=cldsService.unDeployModel(randomNameModel, cldsService.getModel(randomNameModel)); + assertNotNull(responseEntity); + assertNotNull(responseEntity.getStatusCode()); + model=(CldsModel)responseEntity.getBody(); + assertNotNull(model); + } + + @Test + public void testGetSdcProperties() throws IOException { + JSONAssert.assertEquals( + ResourceFileUtil.getResourceAsString("example/sdc/expected-result/sdc-properties-global.json"), cldsService.getSdcProperties(), + true); } @Test -- cgit 1.2.3-korg