summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSmokowski, Steven <steve.smokowski@att.com>2019-10-04 16:29:52 -0400
committerBenjamin, Max (mb388a) <mb388a@att.com>2019-10-04 16:29:53 -0400
commit7a8dd82a9d97c36cdf2491b41a41a8fef794be63 (patch)
tree8890b02dbecb556e533c79adffeb4b463224bf4e
parentac26fde8ba45fb1244a8e81d509800a67b5eb394 (diff)
Fix issue where user cannot create a recipe via
Fix issue where user cannot create a recipe via rest Issue-ID: SO-2394 Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com> Change-Id: Ia21131a1179cbba2652aae30451a25a90ac00e51
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java22
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServiceRecipe.java10
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfComponentsRecipe.java7
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfRecipe.java9
4 files changed, 47 insertions, 1 deletions
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java
index e1cca8901e..347bce5b17 100644
--- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java
+++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java
@@ -37,6 +37,7 @@ import org.json.JSONException;
import org.junit.Test;
import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.onap.so.adapters.catalogdb.CatalogDbAdapterBaseTest;
+import org.onap.so.db.catalog.beans.ServiceRecipe;
import org.skyscreamer.jsonassert.JSONAssert;
import org.skyscreamer.jsonassert.JSONCompareMode;
import org.springframework.boot.test.web.client.TestRestTemplate;
@@ -52,6 +53,8 @@ public class CatalogDBRestTest extends CatalogDbAdapterBaseTest {
private static final String ECOMP_MSO_CATALOG_V2_VF_MODULES = "ecomp/mso/catalog/v2/vfModules";
+ private static final String SERVICE_RECIPE = "serviceRecipe";
+
private static final String ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES =
"ecomp/mso/catalog/v2/serviceAllottedResources";
@@ -839,6 +842,25 @@ public class CatalogDBRestTest extends CatalogDbAdapterBaseTest {
}
}
+ @Test
+ public void testCreateServiceRecipe() throws JSONException {
+ ServiceRecipe recipe = new ServiceRecipe();
+ recipe.setAction("action");
+ recipe.setDescription("description");
+ recipe.setOrchestrationUri("http://test");
+ recipe.setRecipeTimeout(120);
+ recipe.setServiceModelUUID(serviceUUID);
+ HttpEntity<ServiceRecipe> entity = new HttpEntity<ServiceRecipe>(recipe, headers);
+ headers.set("Accept", MediaType.APPLICATION_JSON);
+
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(SERVICE_RECIPE));
+
+ ResponseEntity<String> response =
+ restTemplate.exchange(builder.toUriString(), HttpMethod.POST, entity, String.class);
+
+ assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatusCode().value());
+ }
+
private String createURLWithPort(String uri) {
return "http://localhost:" + port + uri;
}
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServiceRecipe.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServiceRecipe.java
index 5a241afc3a..9e98041cf8 100644
--- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServiceRecipe.java
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServiceRecipe.java
@@ -25,7 +25,8 @@ import java.util.Date;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
-import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
@@ -46,6 +47,7 @@ public class ServiceRecipe implements Serializable, Recipe {
@Id
@Column(name = "id")
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@BusinessKey
@@ -116,6 +118,7 @@ public class ServiceRecipe implements Serializable, Recipe {
super();
}
+ @Override
public Integer getId() {
return id;
}
@@ -136,6 +139,7 @@ public class ServiceRecipe implements Serializable, Recipe {
this.serviceModelUUID = serviceModelUUID;
}
+ @Override
public String getAction() {
return action;
}
@@ -144,6 +148,7 @@ public class ServiceRecipe implements Serializable, Recipe {
this.action = action;
}
+ @Override
public String getDescription() {
return description;
}
@@ -152,6 +157,7 @@ public class ServiceRecipe implements Serializable, Recipe {
this.description = description;
}
+ @Override
public String getOrchestrationUri() {
return orchestrationUri;
}
@@ -160,6 +166,7 @@ public class ServiceRecipe implements Serializable, Recipe {
this.orchestrationUri = orchestrationUri;
}
+ @Override
public String getParamXsd() {
return paramXsd;
}
@@ -168,6 +175,7 @@ public class ServiceRecipe implements Serializable, Recipe {
this.paramXsd = paramXsd;
}
+ @Override
public Integer getRecipeTimeout() {
return recipeTimeout;
}
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfComponentsRecipe.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfComponentsRecipe.java
index 58e7c6c61c..89121bc7e1 100644
--- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfComponentsRecipe.java
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfComponentsRecipe.java
@@ -23,6 +23,8 @@ package org.onap.so.db.catalog.beans;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import org.apache.commons.lang3.builder.EqualsBuilder;
@@ -38,6 +40,7 @@ public class VnfComponentsRecipe implements Serializable, Recipe {
@Id
@Column(name = "id")
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@BusinessKey
@@ -92,6 +95,7 @@ public class VnfComponentsRecipe implements Serializable, Recipe {
.toHashCode();
}
+ @Override
public Integer getId() {
return id;
}
@@ -100,6 +104,7 @@ public class VnfComponentsRecipe implements Serializable, Recipe {
this.id = id;
}
+ @Override
public String getAction() {
return action;
}
@@ -108,6 +113,7 @@ public class VnfComponentsRecipe implements Serializable, Recipe {
this.action = action;
}
+ @Override
public String getDescription() {
return description;
}
@@ -132,6 +138,7 @@ public class VnfComponentsRecipe implements Serializable, Recipe {
this.vnfType = vnfType;
}
+ @Override
public String getParamXsd() {
return paramXsd;
}
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfRecipe.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfRecipe.java
index 8bf45b52c7..ef3d8761c1 100644
--- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfRecipe.java
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfRecipe.java
@@ -24,6 +24,8 @@ import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.PrePersist;
import javax.persistence.Table;
@@ -42,6 +44,7 @@ public class VnfRecipe implements Serializable, Recipe {
@Id
@Column(name = "id")
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@BusinessKey
@@ -117,6 +120,7 @@ public class VnfRecipe implements Serializable, Recipe {
this.nfRole = nfRole;
}
+ @Override
public String getParamXsd() {
return paramXsd;
}
@@ -133,6 +137,7 @@ public class VnfRecipe implements Serializable, Recipe {
this.vfModuleId = vfModuleId;
}
+ @Override
public Integer getId() {
return id;
}
@@ -141,6 +146,7 @@ public class VnfRecipe implements Serializable, Recipe {
this.id = id;
}
+ @Override
public String getAction() {
return action;
}
@@ -149,6 +155,7 @@ public class VnfRecipe implements Serializable, Recipe {
this.action = action;
}
+ @Override
public String getDescription() {
return description;
}
@@ -157,6 +164,7 @@ public class VnfRecipe implements Serializable, Recipe {
this.description = description;
}
+ @Override
public String getOrchestrationUri() {
return orchestrationUri;
}
@@ -165,6 +173,7 @@ public class VnfRecipe implements Serializable, Recipe {
this.orchestrationUri = orchestrationUri;
}
+ @Override
public Integer getRecipeTimeout() {
return recipeTimeout;
}