From e58e011a89ae5c8ada209a82d9b0f3ad1b0ca58f Mon Sep 17 00:00:00 2001 From: Bogumil Zebek Date: Tue, 26 Mar 2019 14:19:31 +0100 Subject: PNF TC R146092 Change-Id: I27c881a8673957dde346fae393fffa6e946c2cd4 Issue-ID: VNFSDK-388 Signed-off-by: Zebek Bogumil --- .../VTPValidateCSARR293901IntegrationTest.java | 60 +++------------------- 1 file changed, 6 insertions(+), 54 deletions(-) (limited to 'csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR293901IntegrationTest.java') diff --git a/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR293901IntegrationTest.java b/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR293901IntegrationTest.java index eca3c1a..cd1dc06 100644 --- a/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR293901IntegrationTest.java +++ b/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR293901IntegrationTest.java @@ -17,22 +17,15 @@ package org.onap.cvc.csar.cc.sol004; -import com.google.common.collect.Lists; import org.junit.Before; import org.junit.Test; -import org.onap.cli.fw.error.OnapCommandException; -import org.onap.cli.fw.error.OnapCommandInvalidParameterValue; -import org.onap.cli.fw.input.OnapCommandParameter; -import org.onap.cli.fw.output.OnapCommandResult; -import org.onap.cli.fw.output.OnapCommandResultAttribute; import org.onap.cvc.csar.CSARArchive; -import java.net.URISyntaxException; import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; import static org.assertj.core.api.Assertions.assertThat; +import static org.onap.cvc.csar.cc.sol004.IntegrationTestUtils.configureTestCase; +import static org.onap.cvc.csar.cc.sol004.IntegrationTestUtils.convertToMessagesList; public class VTPValidateCSARR293901IntegrationTest { @@ -40,7 +33,7 @@ public class VTPValidateCSARR293901IntegrationTest { private VTPValidateCSARR293901 testCase; @Before - public void setUp(){ + public void setUp() { testCase = new VTPValidateCSARR293901(); } @@ -52,7 +45,7 @@ public class VTPValidateCSARR293901IntegrationTest { @Test public void shouldReportThatMandatoryEntriesAreNotAvailable() throws Exception { // given - configureTestCase(testCase, "pnf/noMandatoryEntriesInTOSCAMeta.csar"); + configureTestCase(testCase, "pnf/r293901/noMandatoryEntriesInTOSCAMeta.csar"); // when testCase.execute(); @@ -70,7 +63,7 @@ public class VTPValidateCSARR293901IntegrationTest { @Test public void shouldDoNotReportAnyErrorWhenAllMandatoryEntriesWereDefined() throws Exception { // given - configureTestCase(testCase, "pnf/allMandatoryEntriesDefinedInTOSCAMeta.csar"); + configureTestCase(testCase, "pnf/r293901/allMandatoryEntriesDefinedInTOSCAMeta.csar"); // when testCase.execute(); @@ -83,7 +76,7 @@ public class VTPValidateCSARR293901IntegrationTest { @Test public void shouldReportAnyErrorWhneThereIsNoTOSCAMetaFileInTOSCADirectory() throws Exception { // given - configureTestCase(testCase, "pnf/noTOSCAMetaInTOSCADirectory.csar"); + configureTestCase(testCase, "pnf/r293901/noTOSCAMetaInTOSCADirectory.csar"); // when testCase.execute(); @@ -98,45 +91,4 @@ public class VTPValidateCSARR293901IntegrationTest { "Missing. Entry [ETSI-Entry-Change-Log]" ); } - - private String resolvePathToFile(String s) throws URISyntaxException { - return VTPValidateCSARR293901IntegrationTest.class.getClassLoader().getResource(s) - .toURI().getPath(); - } - - private void configureTestCase(VTPValidateCSARR293901 testCase, String fileName) throws OnapCommandException, URISyntaxException { - configureCommandAttributes(testCase); - - testCase.initializeSchema("vtp-validate-csar-r293901.yaml"); - - configurePathToCsar(testCase, fileName); - } - - private void configureCommandAttributes(VTPValidateCSARR293901 testCase) { - OnapCommandResult onapCommandResult = new OnapCommandResult(); - OnapCommandResultAttribute onapCommandResultAttributeCode = new OnapCommandResultAttribute(); - onapCommandResultAttributeCode.setName("code"); - OnapCommandResultAttribute onapCommandResultAttributeMessage = new OnapCommandResultAttribute(); - onapCommandResultAttributeMessage.setName("message"); - OnapCommandResultAttribute onapCommandResultAttributeFile = new OnapCommandResultAttribute(); - onapCommandResultAttributeFile.setName("file"); - OnapCommandResultAttribute onapCommandResultAttributeLineNo = new OnapCommandResultAttribute(); - onapCommandResultAttributeLineNo.setName("line-no"); - List records = Lists.newArrayList(onapCommandResultAttributeCode, onapCommandResultAttributeMessage, onapCommandResultAttributeFile, onapCommandResultAttributeLineNo); - onapCommandResult.setRecords(records); - testCase.setResult(onapCommandResult); - } - - private void configurePathToCsar(VTPValidateCSARR293901 testCase, String fileName) throws URISyntaxException, OnapCommandInvalidParameterValue { - String pathToFile = resolvePathToFile(fileName); - Set parameters = testCase.getParameters(); - OnapCommandParameter csar = parameters.stream().filter(op -> op.getName().equals("csar")).findFirst().get(); - csar.setValue(pathToFile); - } - - private List convertToMessagesList(List errors) { - return errors.stream().map(CSARArchive.CSARError::getMessage).collect(Collectors.toList()); - } - - } \ No newline at end of file -- cgit 1.2.3-korg