use of org.onap.so.asdc.activity.beans.ActivitySpec in project so by onap.
the class ActivitySpecsActionsTest method CreateActivitySpecReturnsCreated_Test.
@Test
public void CreateActivitySpecReturnsCreated_Test() throws Exception {
String HOSTNAME = createURLWithPort("");
ActivitySpec activitySpec = new ActivitySpec();
activitySpec.setName("testActivitySpec");
activitySpec.setDescription("Test Activity Spec");
ActivitySpecCreateResponse activitySpecCreateResponse = new ActivitySpecCreateResponse();
activitySpecCreateResponse.setId("testActivityId");
ObjectMapper mapper = new ObjectMapper();
String body = mapper.writeValueAsString(activitySpecCreateResponse);
wireMockServer.stubFor(post(urlPathMatching("/v1.0/activity-spec")).willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(org.springframework.http.HttpStatus.CREATED.value()).withBody(body)));
String activitySpecId = activitySpecsActions.createActivitySpec(HOSTNAME, activitySpec);
assertEquals("testActivityId", activitySpecId);
}
use of org.onap.so.asdc.activity.beans.ActivitySpec in project so by onap.
the class DeployActivitySpecsTest method mapActivitySpecFromCatalogToSdc_Test.
@Test
public void mapActivitySpecFromCatalogToSdc_Test() throws Exception {
ObjectMapper mapper = new ObjectMapper();
org.onap.so.db.catalog.beans.ActivitySpec catalogActivitySpec = mapper.readValue(new String(Files.readAllBytes(Paths.get("src/test/resources/ActivitySpecFromCatalog.json"))), org.onap.so.db.catalog.beans.ActivitySpec.class);
ActivitySpec activitySpec = deployActivitySpecs.mapActivitySpecFromCatalogToSdc(catalogActivitySpec);
ActivitySpec expected = mapper.readValue(new String(Files.readAllBytes(Paths.get("src/test/resources/ActivitySpec.json"))), ActivitySpec.class);
assertThat(expected, sameBeanAs(activitySpec));
}
use of org.onap.so.asdc.activity.beans.ActivitySpec in project so by onap.
the class DeployActivitySpecs method mapActivitySpecFromCatalogToSdc.
public ActivitySpec mapActivitySpecFromCatalogToSdc(org.onap.so.db.catalog.beans.ActivitySpec activitySpecFromCatalog) {
ActivitySpec activitySpec = new ActivitySpec();
activitySpec.setName(activitySpecFromCatalog.getName());
activitySpec.setDescription(activitySpecFromCatalog.getDescription());
mapCategoryList(activitySpecFromCatalog.getActivitySpecActivitySpecCategories(), activitySpec);
mapInputsAndOutputs(activitySpecFromCatalog.getActivitySpecActivitySpecParameters(), activitySpec);
return activitySpec;
}
use of org.onap.so.asdc.activity.beans.ActivitySpec in project so by onap.
the class DeployActivitySpecs method deployActivities.
@Transactional
public void deployActivities() {
String hostname = env.getProperty(SDC_ENDPOINT);
logger.debug("{} {}", "SDC ActivitySpec endpoint: ", hostname);
if (hostname == null || hostname.isEmpty()) {
logger.warn("The hostname for SDC activities deployment is not configured in SO");
return;
}
if (!checkHttpServerUp(hostname)) {
logger.warn("The sdc end point is not alive");
return;
}
List<org.onap.so.db.catalog.beans.ActivitySpec> activitySpecsFromCatalog = activitySpecRepository.findAll();
for (org.onap.so.db.catalog.beans.ActivitySpec activitySpecFromCatalog : activitySpecsFromCatalog) {
logger.debug("{} {}", "Attempting to create activity ", activitySpecFromCatalog.getName());
ActivitySpec activitySpec = mapActivitySpecFromCatalogToSdc(activitySpecFromCatalog);
String activitySpecId = activitySpecsActions.createActivitySpec(hostname, activitySpec);
if (activitySpecId == null) {
logger.info(LoggingAnchor.TWO, "Failed to create activitySpec", activitySpec.getName());
continue;
}
logger.info(LoggingAnchor.TWO, "Successfully created activitySpec", activitySpec.getName());
boolean certificationResult = activitySpecsActions.certifyActivitySpec(hostname, activitySpecId);
if (!certificationResult) {
logger.info(LoggingAnchor.TWO, "Failed to certify activitySpec", activitySpec.getName());
continue;
}
logger.info(LoggingAnchor.TWO, "Successfully certified activitySpec", activitySpec.getName());
}
}
use of org.onap.so.asdc.activity.beans.ActivitySpec in project so by onap.
the class ActivitySpecsActionsTest method CreateActivitySpecReturnsExists_Test.
@Test
public void CreateActivitySpecReturnsExists_Test() throws Exception {
String HOSTNAME = createURLWithPort("");
ActivitySpec activitySpec = new ActivitySpec();
activitySpec.setName("testActivitySpec");
activitySpec.setDescription("Test Activity Spec");
ActivitySpecCreateResponse activitySpecCreateResponse = new ActivitySpecCreateResponse();
activitySpecCreateResponse.setId("testActivityId");
ObjectMapper mapper = new ObjectMapper();
String body = mapper.writeValueAsString(activitySpecCreateResponse);
wireMockServer.stubFor(post(urlPathMatching("/v1.0/activity-spec")).willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(org.springframework.http.HttpStatus.UNPROCESSABLE_ENTITY.value()).withBody(body)));
String activitySpecId = activitySpecsActions.createActivitySpec(HOSTNAME, activitySpec);
assertEquals(null, activitySpecId);
}
Aggregations