summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/onap/pomba/contextbuilder/sdc/model/handlers/ToscaModelConverter.java6
-rw-r--r--src/test/java/org/onap/pomba/contextbuilder/sdc/model/test/ArtifactInfoTest.java4
-rw-r--r--src/test/java/org/onap/pomba/contextbuilder/sdc/model/test/SDCContextRequestTest.java8
-rw-r--r--src/test/java/org/onap/pomba/contextbuilder/sdc/test/JerseyConfigurationTest.java1
-rw-r--r--src/test/java/org/onap/pomba/contextbuilder/sdc/test/SDCContextConfigTest.java3
-rw-r--r--src/test/java/org/onap/pomba/contextbuilder/sdc/test/ToscaBuildConfigTest.java6
-rw-r--r--src/test/java/org/onap/pomba/contextbuilder/sdc/unittest/service/SDCContextBuilderTest.java68
-rw-r--r--src/test/java/org/onap/pomba/contextbuilder/sdc/unittest/service/SDCContextRestAPITest.java22
8 files changed, 89 insertions, 29 deletions
diff --git a/src/main/java/org/onap/pomba/contextbuilder/sdc/model/handlers/ToscaModelConverter.java b/src/main/java/org/onap/pomba/contextbuilder/sdc/model/handlers/ToscaModelConverter.java
index ba6a37b..1e7580d 100644
--- a/src/main/java/org/onap/pomba/contextbuilder/sdc/model/handlers/ToscaModelConverter.java
+++ b/src/main/java/org/onap/pomba/contextbuilder/sdc/model/handlers/ToscaModelConverter.java
@@ -48,7 +48,7 @@ public class ToscaModelConverter {
public static ModelContext convert(ISdcCsarHelper helper) throws ToscaCsarException {
ModelContext context = new ModelContext();
context.setService(generateService(helper.getServiceMetadata()));
- context.setVf(generateVfList(helper));
+ context.setVfs(generateVfList(helper));
return context;
}
@@ -86,7 +86,7 @@ public class ToscaModelConverter {
vf.setUuid(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
String customizationUUID = vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
- vf.setVnfc(generateVnfcList(helper.getVfcListByVf(customizationUUID)));
+ vf.setVnfcs(generateVnfcList(helper.getVfcListByVf(customizationUUID)));
vf.setVfModules(generateVfModuleList(helper.getVfModulesByVf(customizationUUID)));
vfList.add(vf);
@@ -110,7 +110,7 @@ public class ToscaModelConverter {
Object nfcNamingCode = vfcNodeTemplate.getPropertyValue(PROPERTY_NAME_NFC_NAMING_CODE);
if (nfcNamingCode != null) {
- vnfc.setNfcNamingCode((String)nfcNamingCode);
+ vnfc.setType((String)nfcNamingCode);
}
vnfcList.add(vnfc);
diff --git a/src/test/java/org/onap/pomba/contextbuilder/sdc/model/test/ArtifactInfoTest.java b/src/test/java/org/onap/pomba/contextbuilder/sdc/model/test/ArtifactInfoTest.java
index ff4584c..01902f0 100644
--- a/src/test/java/org/onap/pomba/contextbuilder/sdc/model/test/ArtifactInfoTest.java
+++ b/src/test/java/org/onap/pomba/contextbuilder/sdc/model/test/ArtifactInfoTest.java
@@ -15,9 +15,11 @@
* limitations under the License.
* ============LICENSE_END=====================================================
*/
+
package org.onap.pomba.contextbuilder.sdc.model.test;
import static org.junit.Assert.assertEquals;
+
import org.junit.Test;
import org.onap.pomba.contextbuilder.sdc.model.ArtifactInfo;
import org.openecomp.sdc.api.notification.IArtifactInfo;
@@ -38,7 +40,7 @@ public class ArtifactInfoTest {
artifact.setArtifactUUID("ae04b88e-e2ee-4ce9-a62d-3d08cf0f46db");
artifact.setArtifactVersion("artifactVersion");
- IArtifactInfo generatedArtifactTest=(IArtifactInfo)artifact;
+ IArtifactInfo generatedArtifactTest = (IArtifactInfo)artifact;
artifact.setGeneratedArtifact(generatedArtifactTest);
assertEquals(artifactType, artifact.getArtifactType());
diff --git a/src/test/java/org/onap/pomba/contextbuilder/sdc/model/test/SDCContextRequestTest.java b/src/test/java/org/onap/pomba/contextbuilder/sdc/model/test/SDCContextRequestTest.java
index e7ace4b..976af8f 100644
--- a/src/test/java/org/onap/pomba/contextbuilder/sdc/model/test/SDCContextRequestTest.java
+++ b/src/test/java/org/onap/pomba/contextbuilder/sdc/model/test/SDCContextRequestTest.java
@@ -15,6 +15,7 @@
* limitations under the License.
* ============LICENSE_END=====================================================
*/
+
package org.onap.pomba.contextbuilder.sdc.model.test;
import static org.junit.Assert.assertEquals;
@@ -30,11 +31,14 @@ public class SDCContextRequestTest {
@Test
public void testSDCContextRequest() throws Exception {
- String authorization = "Basic " + Base64.getEncoder().encodeToString(("admin" + ":" + "admin").getBytes(StandardCharsets.UTF_8));
+ String authorization = "Basic "
+ + Base64.getEncoder()
+ .encodeToString(("admin" + ":" + "admin")
+ .getBytes(StandardCharsets.UTF_8));
String fromAppId = "POMBA";
String transactionId = UUID.randomUUID().toString();
String serviceInstanceId = "b06270ab-99e6-4a58-9bc0-db2df5c36f4d";
- String modelVersionId= "e9851a43-c068-4eb2-9fe7-2d123bd94ff0";
+ String modelVersionId = "e9851a43-c068-4eb2-9fe7-2d123bd94ff0";
String modelInvariantId = "4fd21763-23ed-4f69-8654-e121626df327" ;
SDCContextRequest sdcContext = new SDCContextRequest(null, authorization, fromAppId, transactionId,
diff --git a/src/test/java/org/onap/pomba/contextbuilder/sdc/test/JerseyConfigurationTest.java b/src/test/java/org/onap/pomba/contextbuilder/sdc/test/JerseyConfigurationTest.java
index f10ac09..d1c09e0 100644
--- a/src/test/java/org/onap/pomba/contextbuilder/sdc/test/JerseyConfigurationTest.java
+++ b/src/test/java/org/onap/pomba/contextbuilder/sdc/test/JerseyConfigurationTest.java
@@ -15,6 +15,7 @@
* limitations under the License.
* ============LICENSE_END=====================================================
*/
+
package org.onap.pomba.contextbuilder.sdc.test;
import static org.junit.Assert.assertEquals;
diff --git a/src/test/java/org/onap/pomba/contextbuilder/sdc/test/SDCContextConfigTest.java b/src/test/java/org/onap/pomba/contextbuilder/sdc/test/SDCContextConfigTest.java
index a02fffd..f760255 100644
--- a/src/test/java/org/onap/pomba/contextbuilder/sdc/test/SDCContextConfigTest.java
+++ b/src/test/java/org/onap/pomba/contextbuilder/sdc/test/SDCContextConfigTest.java
@@ -15,6 +15,7 @@
* limitations under the License.
* ============LICENSE_END=====================================================
*/
+
package org.onap.pomba.contextbuilder.sdc.test;
import static org.junit.Assert.assertEquals;
@@ -28,7 +29,7 @@ public class SDCContextConfigTest {
@Test
public void testSDCContextConfig() throws Exception {
- SDCContextConfig sdcContextConfig= new SDCContextConfig();
+ SDCContextConfig sdcContextConfig = new SDCContextConfig();
sdcContextConfig.setUser("pomba");
sdcContextConfig.setAsdcAddress("10.69.100.139");
diff --git a/src/test/java/org/onap/pomba/contextbuilder/sdc/test/ToscaBuildConfigTest.java b/src/test/java/org/onap/pomba/contextbuilder/sdc/test/ToscaBuildConfigTest.java
index a346dd3..b865dc1 100644
--- a/src/test/java/org/onap/pomba/contextbuilder/sdc/test/ToscaBuildConfigTest.java
+++ b/src/test/java/org/onap/pomba/contextbuilder/sdc/test/ToscaBuildConfigTest.java
@@ -15,10 +15,12 @@
* limitations under the License.
* ============LICENSE_END=====================================================
*/
+
package org.onap.pomba.contextbuilder.sdc.test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
+
import org.junit.Test;
import org.onap.pomba.contextbuilder.sdc.ToscaBuilderConfig;
@@ -29,7 +31,7 @@ public class ToscaBuildConfigTest {
public void testToscaBuilderConfig() throws Exception {
String urlTemplate = "/sdc/v1/catalog/services/e9851a43-c068-4eb2-9fe7-2d123bd94ff0/toscaModel";
- ToscaBuilderConfig configTest= new ToscaBuilderConfig();
+ ToscaBuilderConfig configTest = new ToscaBuilderConfig();
configTest.setCsarFilePrefix("csar-");
configTest.setCsarFileSuffix(".zip");
configTest.setArtifactType("TOSCA_CSAR");
@@ -42,7 +44,7 @@ public class ToscaBuildConfigTest {
assertEquals(urlTemplate, configTest.getUrlTemplate());
assertEquals("/src/test/toscaModel.zip", configTest.getTestToscaCsarFile());
- String str= configTest.toString();
+ String str = configTest.toString();
assertTrue(str.contains("TOSCA_CSAR"));
assertTrue(str.contains("csar-"));
assertTrue(str.contains(".zip"));
diff --git a/src/test/java/org/onap/pomba/contextbuilder/sdc/unittest/service/SDCContextBuilderTest.java b/src/test/java/org/onap/pomba/contextbuilder/sdc/unittest/service/SDCContextBuilderTest.java
index e5e584f..8ec198f 100644
--- a/src/test/java/org/onap/pomba/contextbuilder/sdc/unittest/service/SDCContextBuilderTest.java
+++ b/src/test/java/org/onap/pomba/contextbuilder/sdc/unittest/service/SDCContextBuilderTest.java
@@ -15,6 +15,7 @@
* limitations under the License.
* ============LICENSE_END=====================================================
*/
+
package org.onap.pomba.contextbuilder.sdc.unittest.service;
import static org.junit.Assert.assertEquals;
@@ -50,7 +51,9 @@ import org.springframework.test.context.web.WebAppConfiguration;
public class SDCContextBuilderTest {
static {
- System.setProperty("test.tosca.csar.file", Paths.get(System.getProperty("user.dir"), "src/test/resources/toscaModel.csar.zip").toString());
+ System.setProperty("test.tosca.csar.file",
+ Paths.get(System.getProperty("user.dir"),
+ "src/test/resources/toscaModel.csar.zip").toString());
}
@@ -60,11 +63,14 @@ public class SDCContextBuilderTest {
private SpringService springService;
- private String authorization = "Basic " + Base64.getEncoder().encodeToString(("admin" + ":" + "admin").getBytes(StandardCharsets.UTF_8));
+ private String authorization = "Basic "
+ + Base64.getEncoder()
+ .encodeToString(("admin" + ":" + "admin")
+ .getBytes(StandardCharsets.UTF_8));
private String fromAppId = "POMBA";
private String transactionId = UUID.randomUUID().toString();
private String serviceInstanceId = "b06270ab-99e6-4a58-9bc0-db2df5c36f4d";
- private String modelVersionId= "e9851a43-c068-4eb2-9fe7-2d123bd94ff0";
+ private String modelVersionId = "e9851a43-c068-4eb2-9fe7-2d123bd94ff0";
private String modelInvariantId = "4fd21763-23ed-4f69-8654-e121626df327" ;
@Before
@@ -78,21 +84,39 @@ public class SDCContextBuilderTest {
@Test
public void testNoAuthHeader() throws Exception {
- Response response = this.service.getContext(null, fromAppId, transactionId, serviceInstanceId, modelVersionId, modelInvariantId);
+ Response response = this.service.getContext(null,
+ fromAppId,
+ transactionId,
+ serviceInstanceId,
+ modelVersionId,
+ modelInvariantId);
assertEquals(Status.UNAUTHORIZED.getStatusCode(), response.getStatus());
}
@Test
public void testBadAuthoriztion() throws Exception {
- String authorizationTest = "Basic " + Base64.getEncoder().encodeToString(("Test" + ":" + "Fake").getBytes(StandardCharsets.UTF_8));
- Response response = this.service.getContext(authorizationTest, fromAppId, transactionId, serviceInstanceId, modelVersionId, modelInvariantId);
+ String authorizationTest = "Basic "
+ + Base64.getEncoder()
+ .encodeToString(("Test" + ":" + "Fake")
+ .getBytes(StandardCharsets.UTF_8));
+ Response response = this.service.getContext(authorizationTest,
+ fromAppId,
+ transactionId,
+ serviceInstanceId,
+ modelVersionId,
+ modelInvariantId);
assertEquals(Status.UNAUTHORIZED.getStatusCode(), response.getStatus());
}
@Test
public void testNullXFromAppId() throws Exception {
- Response response = this.service.getContext(authorization, null, transactionId, serviceInstanceId, modelVersionId, modelInvariantId);
+ Response response = this.service.getContext(authorization,
+ null,
+ transactionId,
+ serviceInstanceId,
+ modelVersionId,
+ modelInvariantId);
assertEquals(Status.BAD_REQUEST.getStatusCode(), response.getStatus());
assertTrue(((String)response.getEntity()).contains("X-FromAppId"));
}
@@ -100,7 +124,12 @@ public class SDCContextBuilderTest {
@Test
public void testEmptyXFromAppId() throws Exception {
- Response response = this.service.getContext(authorization, "", transactionId, serviceInstanceId, modelVersionId, modelInvariantId);
+ Response response = this.service.getContext(authorization,
+ "",
+ transactionId,
+ serviceInstanceId,
+ modelVersionId,
+ modelInvariantId);
assertEquals(Status.BAD_REQUEST.getStatusCode(), response.getStatus());
assertTrue(((String)response.getEntity()).contains("X-FromAppId"));
}
@@ -108,7 +137,12 @@ public class SDCContextBuilderTest {
@Test
public void testNullModelVersionId() throws Exception {
- Response response = this.service.getContext(authorization, fromAppId, transactionId, serviceInstanceId, null, modelInvariantId);
+ Response response = this.service.getContext(authorization,
+ fromAppId,
+ transactionId,
+ serviceInstanceId,
+ null,
+ modelInvariantId);
assertEquals(Status.BAD_REQUEST.getStatusCode(), response.getStatus());
assertTrue(((String)response.getEntity()).contains("modelVersionId"));
}
@@ -116,7 +150,12 @@ public class SDCContextBuilderTest {
@Test
public void testEmptyModelVersionId() throws Exception {
- Response response = this.service.getContext(authorization, fromAppId, transactionId, serviceInstanceId, "", modelInvariantId);
+ Response response = this.service.getContext(authorization,
+ fromAppId,
+ transactionId,
+ serviceInstanceId,
+ "",
+ modelInvariantId);
assertEquals(Status.BAD_REQUEST.getStatusCode(), response.getStatus());
assertTrue(((String)response.getEntity()).contains("modelVersionId"));
}
@@ -124,7 +163,12 @@ public class SDCContextBuilderTest {
@Test
public void testRestAPISuccess() throws Exception {
- Response response = this.service.getContext(authorization, fromAppId, transactionId, serviceInstanceId, modelVersionId, modelInvariantId);
+ Response response = this.service.getContext(authorization,
+ fromAppId,
+ transactionId,
+ serviceInstanceId,
+ modelVersionId,
+ modelInvariantId);
assertEquals(200, response.getStatus());
}
@@ -135,7 +179,7 @@ public class SDCContextBuilderTest {
serviceInstanceId, modelVersionId, modelInvariantId);
SDCContextResponse sdcResponse = springService.getModelData(request);
assertTrue(sdcResponse.getModelData().contains("service"));
- assertTrue(sdcResponse.getModelData().contains("vf-list"));
+ assertTrue(sdcResponse.getModelData().contains("vfList"));
}
diff --git a/src/test/java/org/onap/pomba/contextbuilder/sdc/unittest/service/SDCContextRestAPITest.java b/src/test/java/org/onap/pomba/contextbuilder/sdc/unittest/service/SDCContextRestAPITest.java
index 6f42584..696292e 100644
--- a/src/test/java/org/onap/pomba/contextbuilder/sdc/unittest/service/SDCContextRestAPITest.java
+++ b/src/test/java/org/onap/pomba/contextbuilder/sdc/unittest/service/SDCContextRestAPITest.java
@@ -15,9 +15,9 @@
* limitations under the License.
* ============LICENSE_END=====================================================
*/
+
package org.onap.pomba.contextbuilder.sdc.unittest.service;
-import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.nio.charset.StandardCharsets;
@@ -54,11 +54,14 @@ public class SDCContextRestAPITest {
private RestService service;
- private String authorization = "Basic " + Base64.getEncoder().encodeToString(("admin" + ":" + "admin").getBytes(StandardCharsets.UTF_8));
+ private String authorization = "Basic "
+ + Base64.getEncoder()
+ .encodeToString(("admin" + ":" + "admin")
+ .getBytes(StandardCharsets.UTF_8));
private String fromAppId = "POMBA";
private String transactionId = UUID.randomUUID().toString();
private String serviceInstanceId = "b06270ab-99e6-4a58-9bc0-db2df5c36f4d";
- private String modelVersionId= "e9851a43-c068-4eb2-9fe7-2d123bd94ff0";
+ private String modelVersionId = "e9851a43-c068-4eb2-9fe7-2d123bd94ff0";
private String modelInvariantId = "4fd21763-23ed-4f69-8654-e121626df327" ;
@Before
@@ -72,19 +75,22 @@ public class SDCContextRestAPITest {
}
/**
- * Call to SDC to download the Tosca Csar file
+ * Call to SDC to download the Tosca Csar file.
*
*/
@Test
public void testVerifyAPI() throws Exception {
//TODO we need mock the localhost as SDC to return success. For now, assume it failed to reach the SDC
try {
- this.service.getContext(authorization, fromAppId, transactionId, serviceInstanceId, modelVersionId, modelInvariantId);
- }catch (ToscaCsarException x) {
+ this.service.getContext(authorization,
+ fromAppId,
+ transactionId,
+ serviceInstanceId,
+ modelVersionId,
+ modelInvariantId);
+ } catch (ToscaCsarException x) {
fail("Failed to retrieve CSAR artifact from SDC");
}
}
-
-
}