diff options
author | sebdet <sd378r@intl.att.com> | 2018-09-19 18:35:11 +0200 |
---|---|---|
committer | sebdet <sd378r@intl.att.com> | 2018-09-19 18:35:11 +0200 |
commit | a9cdc79ba7e928b38ed132d38426b6c8b70635bf (patch) | |
tree | 20f7b67c10d21d7d937dbad53533ffb4c53fcb56 /src/test/java/org | |
parent | 31b7e68cce37f171af2859e884f35d5d00ecc811 (diff) |
Add tests
Add some tests to cldsService
Issue-ID: CLAMP-217
Change-Id: I95f21306f3d807a283519604c1711dfd07466d4a
Signed-off-by: sebdet <sd378r@intl.att.com>
Diffstat (limited to 'src/test/java/org')
-rw-r--r-- | src/test/java/org/onap/clamp/clds/it/CldsServiceItCase.java | 33 |
1 files changed, 31 insertions, 2 deletions
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 |