diff options
author | sebdet <sebastien.determe@intl.att.com> | 2018-10-24 18:03:29 +0200 |
---|---|---|
committer | sebdet <sebastien.determe@intl.att.com> | 2018-10-24 18:33:42 +0200 |
commit | 447d81c985e893c5a5b6b5305cb4e7975717b75b (patch) | |
tree | 4e897d7f2fe3dbcb41e8345d3730a8bd58adb553 /src/test/java/org | |
parent | ce46c2d4a22e19575ac7e07a60ebf22d8313cc91 (diff) |
Fix sonar bug
Fix sonar bug reported due to InterruptedException caught and not thrown
Issue-ID: CLAMP-217
Change-Id: Icb0f6fadd01df811fb2424dfdfaa96bb8f996d68
Signed-off-by: sebdet <sebastien.determe@intl.att.com>
Diffstat (limited to 'src/test/java/org')
-rw-r--r-- | src/test/java/org/onap/clamp/clds/it/sdc/controller/installer/CsarInstallerItCase.java | 51 |
1 files changed, 25 insertions, 26 deletions
diff --git a/src/test/java/org/onap/clamp/clds/it/sdc/controller/installer/CsarInstallerItCase.java b/src/test/java/org/onap/clamp/clds/it/sdc/controller/installer/CsarInstallerItCase.java index 56d29d525..4dd44437c 100644 --- a/src/test/java/org/onap/clamp/clds/it/sdc/controller/installer/CsarInstallerItCase.java +++ b/src/test/java/org/onap/clamp/clds/it/sdc/controller/installer/CsarInstallerItCase.java @@ -18,7 +18,7 @@ * limitations under the License. * ============LICENSE_END============================================ * =================================================================== - * + * */ package org.onap.clamp.clds.it.sdc.controller.installer; @@ -78,28 +78,28 @@ public class CsarInstallerItCase { private CldsDao cldsDao; @Test(expected = SdcArtifactInstallerException.class) - public void testInstallTheCsarFail() - throws SdcArtifactInstallerException, SdcToscaParserException, CsarHandlerException, IOException { + public void testInstallTheCsarFail() throws SdcArtifactInstallerException, SdcToscaParserException, + CsarHandlerException, IOException, InterruptedException { CsarHandler csarHandler = Mockito.mock(CsarHandler.class); BlueprintArtifact blueprintArtifact = Mockito.mock(BlueprintArtifact.class); Mockito.when(blueprintArtifact.getResourceAttached()).thenReturn(Mockito.mock(IResourceInstance.class)); Map<String, BlueprintArtifact> blueprintMap = new HashMap<>(); blueprintMap.put("resourceid", blueprintArtifact); Mockito.when(csarHandler.getMapOfBlueprints()).thenReturn(blueprintMap); - Mockito.when(blueprintArtifact.getDcaeBlueprint()).thenReturn(IOUtils - .toString(ResourceFileUtil.getResourceAsStream("example/sdc/blueprint-dcae/not-recognized.yaml"))); + Mockito.when(blueprintArtifact.getDcaeBlueprint()).thenReturn( + IOUtils.toString(ResourceFileUtil.getResourceAsStream("example/sdc/blueprint-dcae/not-recognized.yaml"))); csarInstaller.installTheCsar(csarHandler); fail("Should have raised an SdcArtifactInstallerException"); } private BlueprintArtifact buildFakeBuildprintArtifact(String instanceName, String invariantResourceUuid, - String blueprintFilePath, String csarArtifactName, String invariantServiceUuid) throws IOException { + String blueprintFilePath, String csarArtifactName, String invariantServiceUuid) throws IOException { IResourceInstance resource = Mockito.mock(IResourceInstance.class); Mockito.when(resource.getResourceInstanceName()).thenReturn(instanceName); Mockito.when(resource.getResourceInvariantUUID()).thenReturn(invariantResourceUuid); BlueprintArtifact blueprintArtifact = Mockito.mock(BlueprintArtifact.class); Mockito.when(blueprintArtifact.getDcaeBlueprint()) - .thenReturn(ResourceFileUtil.getResourceAsString(blueprintFilePath)); + .thenReturn(ResourceFileUtil.getResourceAsString(blueprintFilePath)); Mockito.when(blueprintArtifact.getBlueprintArtifactName()).thenReturn(csarArtifactName); Mockito.when(blueprintArtifact.getBlueprintInvariantServiceUuid()).thenReturn(invariantServiceUuid); Mockito.when(blueprintArtifact.getResourceAttached()).thenReturn(resource); @@ -118,13 +118,13 @@ public class CsarInstallerItCase { Mockito.when(csarHandler.getMapOfBlueprints()).thenReturn(blueprintMap); // Create fake blueprint artifact 1 BlueprintArtifact blueprintArtifact = buildFakeBuildprintArtifact(INSTANCE_NAME_RESOURCE1, - INVARIANT_RESOURCE1_UUID, "example/sdc/blueprint-dcae/tca.yaml", CSAR_ARTIFACT_NAME, - INVARIANT_SERVICE_UUID); + INVARIANT_RESOURCE1_UUID, "example/sdc/blueprint-dcae/tca.yaml", CSAR_ARTIFACT_NAME, + INVARIANT_SERVICE_UUID); listResources.add(blueprintArtifact.getResourceAttached()); blueprintMap.put(blueprintArtifact.getResourceAttached().getResourceInstanceName(), blueprintArtifact); // Create fake blueprint artifact 2 blueprintArtifact = buildFakeBuildprintArtifact(INSTANCE_NAME_RESOURCE2, INVARIANT_RESOURCE2_UUID, - "example/sdc/blueprint-dcae/tca_2.yaml", CSAR_ARTIFACT_NAME, INVARIANT_SERVICE_UUID); + "example/sdc/blueprint-dcae/tca_2.yaml", CSAR_ARTIFACT_NAME, INVARIANT_SERVICE_UUID); listResources.add(blueprintArtifact.getResourceAttached()); blueprintMap.put(blueprintArtifact.getResourceAttached().getResourceInstanceName(), blueprintArtifact); // Build fake csarhandler @@ -139,8 +139,8 @@ public class CsarInstallerItCase { } @Test - public void testIsCsarAlreadyDeployedTca() - throws SdcArtifactInstallerException, SdcToscaParserException, CsarHandlerException, IOException { + public void testIsCsarAlreadyDeployedTca() throws SdcArtifactInstallerException, SdcToscaParserException, + CsarHandlerException, IOException, InterruptedException { String generatedName = RandomStringUtils.randomAlphanumeric(5); CsarHandler csarHandler = buildFakeCsarHandler(generatedName); assertFalse(csarInstaller.isCsarAlreadyDeployed(csarHandler)); @@ -149,40 +149,39 @@ public class CsarInstallerItCase { } @Test - public void testInstallTheCsarTca() - throws SdcArtifactInstallerException, SdcToscaParserException, CsarHandlerException, IOException, JSONException { + public void testInstallTheCsarTca() throws SdcArtifactInstallerException, SdcToscaParserException, + CsarHandlerException, IOException, JSONException, InterruptedException { String generatedName = RandomStringUtils.randomAlphanumeric(5); CsarHandler csar = buildFakeCsarHandler(generatedName); csarInstaller.installTheCsar(csar); CldsModel cldsModel1 = verifyClosedLoopModelLoadedInDb(csar, generatedName, INSTANCE_NAME_RESOURCE1); JSONAssert.assertEquals( - IOUtils.toString( - ResourceFileUtil.getResourceAsStream("example/sdc/blueprint-dcae/prop-text-for-tca.json")), - cldsModel1.getPropText(), true); + IOUtils.toString(ResourceFileUtil.getResourceAsStream("example/sdc/blueprint-dcae/prop-text-for-tca.json")), + cldsModel1.getPropText(), true); CldsModel cldsModel2 = verifyClosedLoopModelLoadedInDb(csar, generatedName, INSTANCE_NAME_RESOURCE2); JSONAssert.assertEquals( - IOUtils.toString( - ResourceFileUtil.getResourceAsStream("example/sdc/blueprint-dcae/prop-text-for-tca-2.json")), - cldsModel2.getPropText(), true); + IOUtils + .toString(ResourceFileUtil.getResourceAsStream("example/sdc/blueprint-dcae/prop-text-for-tca-2.json")), + cldsModel2.getPropText(), true); } private CldsModel verifyClosedLoopModelLoadedInDb(CsarHandler csar, String generatedName, - String instanceNameResource) throws SdcArtifactInstallerException { + String instanceNameResource) throws SdcArtifactInstallerException { // Get the template back from DB CldsTemplate templateFromDb = CldsTemplate.retrieve(cldsDao, - CsarInstallerImpl.TEMPLATE_NAME_PREFIX + CsarInstallerImpl.buildModelName(csar, instanceNameResource), - false); + CsarInstallerImpl.TEMPLATE_NAME_PREFIX + CsarInstallerImpl.buildModelName(csar, instanceNameResource), + false); assertNotNull(templateFromDb); assertNotNull(templateFromDb.getBpmnText()); assertNotNull(templateFromDb.getImageText()); assertNotNull(templateFromDb.getPropText()); assertTrue(templateFromDb.getPropText().contains("global") - && templateFromDb.getPropText().contains("node_templates:")); + && templateFromDb.getPropText().contains("node_templates:")); assertEquals(templateFromDb.getName(), - CsarInstallerImpl.TEMPLATE_NAME_PREFIX + CsarInstallerImpl.buildModelName(csar, instanceNameResource)); + CsarInstallerImpl.TEMPLATE_NAME_PREFIX + CsarInstallerImpl.buildModelName(csar, instanceNameResource)); // Get the Model back from DB CldsModel modelFromDb = CldsModel.retrieve(cldsDao, - CsarInstallerImpl.buildModelName(csar, instanceNameResource), true); + CsarInstallerImpl.buildModelName(csar, instanceNameResource), true); assertNotNull(modelFromDb); assertNotNull(modelFromDb.getBpmnText()); assertNotNull(modelFromDb.getImageText()); |