aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/onap/clamp/clds/Application.java8
-rw-r--r--src/main/java/org/onap/clamp/clds/ClampInUserAuditorAware.java46
-rw-r--r--src/main/java/org/onap/clamp/clds/filter/ClampCadiFilter.java2
-rw-r--r--src/main/java/org/onap/clamp/clds/model/CldsDictionary.java159
-rw-r--r--src/main/java/org/onap/clamp/clds/model/CldsDictionaryItem.java214
-rw-r--r--src/main/java/org/onap/clamp/clds/tosca/ToscaYamlToJsonConvertor.java57
-rw-r--r--src/main/java/org/onap/clamp/loop/Loop.java25
-rw-r--r--src/main/java/org/onap/clamp/loop/LoopService.java26
-rw-r--r--src/main/java/org/onap/clamp/loop/LoopsRepository.java5
-rw-r--r--src/main/java/org/onap/clamp/loop/common/AuditEntity.java108
-rw-r--r--src/main/java/org/onap/clamp/loop/log/LoopLog.java2
-rw-r--r--src/main/java/org/onap/clamp/loop/log/LoopLogRepository.java4
-rw-r--r--src/main/java/org/onap/clamp/loop/service/Service.java18
-rw-r--r--src/main/java/org/onap/clamp/loop/service/ServicesRepository.java31
-rw-r--r--src/main/java/org/onap/clamp/loop/template/LoopTemplate.java268
-rw-r--r--src/main/java/org/onap/clamp/loop/template/LoopTemplatesRepository.java37
-rw-r--r--src/main/java/org/onap/clamp/loop/template/MicroServiceModel.java217
-rw-r--r--src/main/java/org/onap/clamp/loop/template/MicroServiceModelsRepository.java31
-rw-r--r--src/main/java/org/onap/clamp/loop/template/PolicyModel.java239
-rw-r--r--src/main/java/org/onap/clamp/loop/template/PolicyModelId.java93
-rw-r--r--src/main/java/org/onap/clamp/loop/template/PolicyModelsRepository.java38
-rw-r--r--src/main/java/org/onap/clamp/loop/template/PolicyModelsService.java59
-rw-r--r--src/main/java/org/onap/clamp/loop/template/TemplateMicroServiceModel.java194
-rw-r--r--src/main/java/org/onap/clamp/loop/template/TemplateMicroServiceModelId.java102
-rw-r--r--src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java64
-rw-r--r--src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicyRepository.java4
-rw-r--r--src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicyService.java (renamed from src/main/java/org/onap/clamp/policy/microservice/MicroservicePolicyService.java)4
-rw-r--r--src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java35
-rw-r--r--src/main/java/org/onap/clamp/policy/operational/OperationalPolicyRepository.java4
-rw-r--r--src/main/java/org/onap/clamp/tosca/Dictionary.java174
-rw-r--r--src/main/java/org/onap/clamp/tosca/DictionaryElement.java249
-rw-r--r--src/main/java/org/onap/clamp/tosca/DictionaryElementsRepository.java32
-rw-r--r--src/main/java/org/onap/clamp/tosca/DictionaryRepository.java38
-rw-r--r--src/main/java/org/onap/clamp/util/SemanticVersioning.java76
-rw-r--r--src/main/resources/META-INF/resources/swagger.html411
-rw-r--r--src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java6
-rw-r--r--src/test/java/org/onap/clamp/loop/LoopControllerTestItCase.java30
-rw-r--r--src/test/java/org/onap/clamp/loop/LoopLogServiceTestItCase.java4
-rw-r--r--src/test/java/org/onap/clamp/loop/LoopRepositoriesItCase.java137
-rw-r--r--src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java84
-rw-r--r--src/test/java/org/onap/clamp/loop/LoopToJsonTest.java37
-rw-r--r--src/test/java/org/onap/clamp/loop/PolicyModelServiceItCase.java161
-rw-r--r--src/test/java/org/onap/clamp/util/SemanticVersioningTest.java71
43 files changed, 2995 insertions, 609 deletions
diff --git a/src/main/java/org/onap/clamp/clds/Application.java b/src/main/java/org/onap/clamp/clds/Application.java
index e41140f5c..63320d2fe 100644
--- a/src/main/java/org/onap/clamp/clds/Application.java
+++ b/src/main/java/org/onap/clamp/clds/Application.java
@@ -58,6 +58,7 @@ import org.springframework.boot.web.servlet.support.SpringBootServletInitializer
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.core.env.Environment;
+import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
@@ -65,13 +66,14 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@ComponentScan(basePackages = { "org.onap.clamp" })
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class, SecurityAutoConfiguration.class,
- UserDetailsServiceAutoConfiguration.class })
+ UserDetailsServiceAutoConfiguration.class })
@EnableJpaRepositories(basePackages = { "org.onap.clamp" })
@EntityScan(basePackages = { "org.onap.clamp" })
@EnableTransactionManagement
@EnableConfigurationProperties
@EnableAsync
@EnableScheduling
+@EnableJpaAuditing
public class Application extends SpringBootServletInitializer {
protected static final EELFLogger eelfLogger = EELFManager.getInstance().getLogger(Application.class);
@@ -137,8 +139,6 @@ public class Application extends SpringBootServletInitializer {
return tomcat;
}
-
-
private Connector createRedirectConnector(int redirectSecuredPort) {
if (redirectSecuredPort <= 0) {
eelfLogger.warn("HTTP port redirection to HTTPS is disabled because the HTTPS port is 0 (random port) or -1"
@@ -159,7 +159,7 @@ public class Application extends SpringBootServletInitializer {
if (env.getProperty("server.ssl.key-store") != null) {
KeyStore keystore = KeyStore.getInstance(env.getProperty("server.ssl.key-store-type"));
- String password = PassDecoder.decode(env.getProperty("server.ssl.key-store-password"),
+ String password = PassDecoder.decode(env.getProperty("server.ssl.key-store-password"),
env.getProperty("clamp.config.keyFile"));
String keyStore = env.getProperty("server.ssl.key-store");
InputStream is = ResourceFileUtil.getResourceAsStream(keyStore.replaceAll("classpath:", ""));
diff --git a/src/main/java/org/onap/clamp/clds/ClampInUserAuditorAware.java b/src/main/java/org/onap/clamp/clds/ClampInUserAuditorAware.java
new file mode 100644
index 000000000..d18e7ebf3
--- /dev/null
+++ b/src/main/java/org/onap/clamp/clds/ClampInUserAuditorAware.java
@@ -0,0 +1,46 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2020 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.clds;
+
+import java.util.Optional;
+
+import org.springframework.data.domain.AuditorAware;
+import org.springframework.security.core.context.SecurityContextHolder;
+import org.springframework.security.core.userdetails.UserDetails;
+import org.springframework.stereotype.Component;
+
+@Component
+public class ClampInUserAuditorAware implements AuditorAware<String> {
+
+ @Override
+ public Optional<String> getCurrentAuditor() {
+ if (SecurityContextHolder.getContext().getAuthentication() != null
+ && SecurityContextHolder.getContext().getAuthentication().getPrincipal() != null) {
+ return Optional.of(((UserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal())
+ .getUsername());
+ }
+ return Optional.of("");
+ }
+
+}
diff --git a/src/main/java/org/onap/clamp/clds/filter/ClampCadiFilter.java b/src/main/java/org/onap/clamp/clds/filter/ClampCadiFilter.java
index 9e04bd084..3bbb8a0bc 100644
--- a/src/main/java/org/onap/clamp/clds/filter/ClampCadiFilter.java
+++ b/src/main/java/org/onap/clamp/clds/filter/ClampCadiFilter.java
@@ -153,7 +153,7 @@ public class ClampCadiFilter extends CadiFilter {
URLDecoder.decode(certHeader, StandardCharsets.UTF_8.toString()).getBytes()));
X509Certificate caCert = (X509Certificate) certificateFactory
.generateCertificate(new ByteArrayInputStream(
- ResourceFileUtil.getResourceAsString("clds/aaf/ssl/ca-certs.pem").getBytes()));
+ ResourceFileUtil.getResourceAsString("clds/aaf/ssl/ca-certs.pem").getBytes()));
X509Certificate[] certifArray = ((X509Certificate[]) request
.getAttribute("javax.servlet.request.X509Certificate"));
diff --git a/src/main/java/org/onap/clamp/clds/model/CldsDictionary.java b/src/main/java/org/onap/clamp/clds/model/CldsDictionary.java
deleted file mode 100644
index 35fbcec46..000000000
--- a/src/main/java/org/onap/clamp/clds/model/CldsDictionary.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.model;
-
-import com.google.gson.annotations.Expose;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Represents a CLDS Dictionary.
- */
-
-public class CldsDictionary {
-
- @Expose
- private String dictionaryId;
- @Expose
- private String dictionaryName;
-
- @Expose
- private String createdBy;
- @Expose
- private String updatedBy;
- @Expose
- private String lastUpdatedDate;
- @Expose
- private List<CldsDictionaryItem> cldsDictionaryItems = new ArrayList<>();
-
- /**
- * Get the dictionary ID.
- *
- * @return the dictionaryId
- */
- public String getDictionaryId() {
- return dictionaryId;
- }
-
- /**
- * Set the dictionary Id.
- *
- * @param dictionaryId the dictionaryId to set
- */
- public void setDictionaryId(String dictionaryId) {
- this.dictionaryId = dictionaryId;
- }
-
- /**
- * Get the dictionary name.
- *
- * @return the dictionaryName
- */
- public String getDictionaryName() {
- return dictionaryName;
- }
-
- /**
- * Set the dictionary name.
- *
- * @param dictionaryName the dictionaryName to set
- */
- public void setDictionaryName(String dictionaryName) {
- this.dictionaryName = dictionaryName;
- }
-
- /**
- * Get the createdBy info.
- *
- * @return the createdBy
- */
- public String getCreatedBy() {
- return createdBy;
- }
-
- /**
- * Set the createdBy info.
- *
- * @param createdBy the createdBy to set
- */
- public void setCreatedBy(String createdBy) {
- this.createdBy = createdBy;
- }
-
- /**
- * Get the updatedBy info.
- *
- * @return the updatedBy
- */
- public String getUpdatedBy() {
- return updatedBy;
- }
-
- /**
- * Set the updatedBy info.
- *
- * @param updatedby the updatedBy to set
- */
- public void setUpdatedBy(String updatedby) {
- updatedBy = updatedby;
- }
-
- /**
- * Get the last updated date.
- *
- * @return the lastUpdatedDate
- */
- public String getLastUpdatedDate() {
- return lastUpdatedDate;
- }
-
- /**
- * Set the last updated date.
- *
- * @param lastUpdatedDate the lastUpdatedDate to set
- */
- public void setLastUpdatedDate(String lastUpdatedDate) {
- this.lastUpdatedDate = lastUpdatedDate;
- }
-
- /**
- * Get all the dictionary items.
- *
- * @return the cldsDictionaryItems
- */
- public List<CldsDictionaryItem> getCldsDictionaryItems() {
- return cldsDictionaryItems;
- }
-
- /**
- * Set the whole dictionary items.
- *
- * @param cldsDictionaryItems the cldsDictionaryItems to set
- */
- public void setCldsDictionaryItems(List<CldsDictionaryItem> cldsDictionaryItems) {
- this.cldsDictionaryItems = cldsDictionaryItems;
- }
-
-}
diff --git a/src/main/java/org/onap/clamp/clds/model/CldsDictionaryItem.java b/src/main/java/org/onap/clamp/clds/model/CldsDictionaryItem.java
deleted file mode 100644
index 1b79bdfa9..000000000
--- a/src/main/java/org/onap/clamp/clds/model/CldsDictionaryItem.java
+++ /dev/null
@@ -1,214 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.model;
-
-import com.google.gson.annotations.Expose;
-
-/**
- * Represents a CLDS Dictionary Item.
- */
-public class CldsDictionaryItem {
-
- @Expose
- private String dictElementId;
- @Expose
- private String dictionaryId;
- @Expose
- private String dictElementName;
- @Expose
- private String dictElementShortName;
- @Expose
- private String dictElementDesc;
- @Expose
- private String dictElementType;
- @Expose
- private String createdBy;
- @Expose
- private String updatedBy;
- @Expose
- private String lastUpdatedDate;
-
- /**
- * Get the dictionary element id.
- *
- * @return the dictElementId
- */
- public String getDictElementId() {
- return dictElementId;
- }
-
- /**
- * Set the dictionary element id.
- *
- * @param dictElementId the dictElementId to set
- */
- public void setDictElementId(String dictElementId) {
- this.dictElementId = dictElementId;
- }
-
- /**
- * Get the dictionary id.
- *
- * @return the dictionaryId
- */
- public String getDictionaryId() {
- return dictionaryId;
- }
-
- /**
- * Set the dictionary id.
- *
- * @param dictionaryId the dictionaryId to set
- */
- public void setDictionaryId(String dictionaryId) {
- this.dictionaryId = dictionaryId;
- }
-
- /**
- * Get the dictionary name.
- *
- * @return the dictElementName
- */
- public String getDictElementName() {
- return dictElementName;
- }
-
- /**
- * Set the dictionary name.
- *
- * @param dictElementName the dictElementName to set
- */
- public void setDictElementName(String dictElementName) {
- this.dictElementName = dictElementName;
- }
-
- /**
- * Get the dictionary element short name.
- *
- * @return the dictElementShortName
- */
- public String getDictElementShortName() {
- return dictElementShortName;
- }
-
- /**
- * Set the dictionary element short name.
- *
- * @param dictElementShortName the dictElementShortName to set
- */
- public void setDictElementShortName(String dictElementShortName) {
- this.dictElementShortName = dictElementShortName;
- }
-
- /**
- * Get the dictionary element description.
- *
- * @return the dictElementDesc
- */
- public String getDictElementDesc() {
- return dictElementDesc;
- }
-
- /**
- * Set the dictionary element description.
- *
- * @param dictElementDesc the dictElementDesc to set
- */
- public void setDictElementDesc(String dictElementDesc) {
- this.dictElementDesc = dictElementDesc;
- }
-
- /**
- * Get the dictionary element type.
- *
- * @return the dictElementType
- */
- public String getDictElementType() {
- return dictElementType;
- }
-
- /**
- * Set the dictionary element type.
- *
- * @param dictElementType the dictElementType to set
- */
- public void setDictElementType(String dictElementType) {
- this.dictElementType = dictElementType;
- }
-
- /**
- * Get the createdBy info.
- *
- * @return the createdBy
- */
- public String getCreatedBy() {
- return createdBy;
- }
-
- /**
- * Set the createdBy info.
- *
- * @param createdBy the createdBy to set
- */
- public void setCreatedBy(String createdBy) {
- this.createdBy = createdBy;
- }
-
- /**
- * Get the updatedBy info.
- *
- * @return the updatedBy
- */
- public String getUpdatedBy() {
- return updatedBy;
- }
-
- /**
- * Set the updatedBy info.
- *
- * @param updatedby the updatedBy to set
- */
- public void setUpdatedBy(String updatedby) {
- updatedBy = updatedby;
- }
-
- /**
- * Get the last updated date.
- *
- * @return the lastUpdatedDate
- */
- public String getLastUpdatedDate() {
- return lastUpdatedDate;
- }
-
- /**
- * Set the last updated date.
- *
- * @param lastUpdatedDate the lastUpdatedDate to set
- */
- public void setLastUpdatedDate(String lastUpdatedDate) {
- this.lastUpdatedDate = lastUpdatedDate;
- }
-
-}
diff --git a/src/main/java/org/onap/clamp/clds/tosca/ToscaYamlToJsonConvertor.java b/src/main/java/org/onap/clamp/clds/tosca/ToscaYamlToJsonConvertor.java
index 43dd5f451..2e025ba7d 100644
--- a/src/main/java/org/onap/clamp/clds/tosca/ToscaYamlToJsonConvertor.java
+++ b/src/main/java/org/onap/clamp/clds/tosca/ToscaYamlToJsonConvertor.java
@@ -481,63 +481,6 @@ public class ToscaYamlToJsonConvertor {
private void processDictionaryElements(JSONObject childObject, String dictionaryReference) {
- /*
- * if (dictionaryReference.contains("#")) { String[] dictionaryKeyArray =
- * dictionaryReference
- * .substring(dictionaryReference.indexOf(ToscaSchemaConstants.DICTIONARY) + 11,
- * dictionaryReference.length()) .split("#"); // We support only one # as of
- * now. List<CldsDictionaryItem> cldsDictionaryElements = null;
- * List<CldsDictionaryItem> subDictionaryElements = null; if (dictionaryKeyArray
- * != null && dictionaryKeyArray.length == 2) { cldsDictionaryElements =
- * getCldsDao().getDictionaryElements(dictionaryKeyArray[0], null, null);
- * subDictionaryElements =
- * getCldsDao().getDictionaryElements(dictionaryKeyArray[1], null, null);
- *
- * if (cldsDictionaryElements != null) { List<String> subCldsDictionaryNames =
- * subDictionaryElements.stream()
- * .map(CldsDictionaryItem::getDictElementShortName).collect(Collectors.toList()
- * ); JSONArray jsonArray = new JSONArray();
- *
- * Optional.ofNullable(cldsDictionaryElements).get().stream().forEach(c -> {
- * JSONObject jsonObject = new JSONObject();
- * jsonObject.put(JsonEditorSchemaConstants.TYPE,
- * getJsonType(c.getDictElementType())); if (c.getDictElementType() != null &&
- * c.getDictElementType().equalsIgnoreCase(ToscaSchemaConstants.TYPE_STRING)) {
- * jsonObject.put(JsonEditorSchemaConstants.MIN_LENGTH, 1); }
- * jsonObject.put(JsonEditorSchemaConstants.ID, c.getDictElementName());
- * jsonObject.put(JsonEditorSchemaConstants.LABEL, c.getDictElementShortName());
- * jsonObject.put(JsonEditorSchemaConstants.OPERATORS, subCldsDictionaryNames);
- * jsonArray.put(jsonObject); }); ; JSONObject filterObject = new JSONObject();
- * filterObject.put(JsonEditorSchemaConstants.FILTERS, jsonArray);
- *
- * childObject.put(JsonEditorSchemaConstants.TYPE,
- * JsonEditorSchemaConstants.TYPE_QBLDR); // TO invoke validation on such
- * parameters childObject.put(JsonEditorSchemaConstants.MIN_LENGTH, 1);
- * childObject.put(JsonEditorSchemaConstants.QSSCHEMA, filterObject);
- *
- * } } } else { String dictionaryKey = dictionaryReference.substring(
- * dictionaryReference.indexOf(ToscaSchemaConstants.DICTIONARY) + 11,
- * dictionaryReference.length()); if (dictionaryKey != null) {
- * List<CldsDictionaryItem> cldsDictionaryElements =
- * getCldsDao().getDictionaryElements(dictionaryKey, null, null); if
- * (cldsDictionaryElements != null) { List<String> cldsDictionaryNames = new
- * ArrayList<>(); List<String> cldsDictionaryFullNames = new ArrayList<>();
- * cldsDictionaryElements.stream().forEach(c -> { // Json type will be
- * translated before Policy creation if (c.getDictElementType() != null &&
- * !c.getDictElementType().equalsIgnoreCase("json")) {
- * cldsDictionaryFullNames.add(c.getDictElementName()); }
- * cldsDictionaryNames.add(c.getDictElementShortName()); });
- *
- * if (cldsDictionaryFullNames.size() > 0) {
- * childObject.put(JsonEditorSchemaConstants.ENUM, cldsDictionaryFullNames); //
- * Add Enum titles for generated translated values during JSON instance //
- * generation JSONObject enumTitles = new JSONObject();
- * enumTitles.put(JsonEditorSchemaConstants.ENUM_TITLES, cldsDictionaryNames);
- * childObject.put(JsonEditorSchemaConstants.OPTIONS, enumTitles); } else {
- * childObject.put(JsonEditorSchemaConstants.ENUM, cldsDictionaryNames); }
- *
- * } } }
- */
}
private String getJsonType(String toscaType) {
diff --git a/src/main/java/org/onap/clamp/loop/Loop.java b/src/main/java/org/onap/clamp/loop/Loop.java
index 531587a75..66046f02b 100644
--- a/src/main/java/org/onap/clamp/loop/Loop.java
+++ b/src/main/java/org/onap/clamp/loop/Loop.java
@@ -56,18 +56,20 @@ import org.hibernate.annotations.Type;
import org.hibernate.annotations.TypeDef;
import org.hibernate.annotations.TypeDefs;
import org.onap.clamp.dao.model.jsontype.StringJsonUserType;
+import org.onap.clamp.loop.common.AuditEntity;
import org.onap.clamp.loop.components.external.DcaeComponent;
import org.onap.clamp.loop.components.external.ExternalComponent;
import org.onap.clamp.loop.components.external.PolicyComponent;
import org.onap.clamp.loop.log.LoopLog;
import org.onap.clamp.loop.service.Service;
+import org.onap.clamp.loop.template.LoopTemplate;
import org.onap.clamp.policy.microservice.MicroServicePolicy;
import org.onap.clamp.policy.operational.OperationalPolicy;
@Entity
@Table(name = "loops")
@TypeDefs({ @TypeDef(name = "json", typeClass = StringJsonUserType.class) })
-public class Loop implements Serializable {
+public class Loop extends AuditEntity implements Serializable {
/**
* The serial version id.
@@ -103,7 +105,7 @@ public class Loop implements Serializable {
private JsonObject globalPropertiesJson;
@Expose
- @ManyToOne(fetch = FetchType.EAGER)
+ @ManyToOne(fetch = FetchType.EAGER, cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH })
@JoinColumn(name = "service_uuid")
private Service modelService;
@@ -120,19 +122,24 @@ public class Loop implements Serializable {
private final Map<String, ExternalComponent> components = new HashMap<>();
@Expose
- @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "loop")
+ @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "loop", orphanRemoval = true)
private Set<OperationalPolicy> operationalPolicies = new HashSet<>();
@Expose
- @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
+ @ManyToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH }, fetch = FetchType.EAGER)
@JoinTable(name = "loops_microservicepolicies", joinColumns = @JoinColumn(name = "loop_id"), inverseJoinColumns = @JoinColumn(name = "microservicepolicy_id"))
private Set<MicroServicePolicy> microServicePolicies = new HashSet<>();
@Expose
- @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "loop")
+ @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "loop", orphanRemoval = true)
@SortNatural
private SortedSet<LoopLog> loopLogs = new TreeSet<>();
+ @Expose
+ @ManyToOne(cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH }, fetch = FetchType.EAGER)
+ @JoinColumn(name = "loop_template_name")
+ private LoopTemplate loopTemplate;
+
private void initializeExternalComponents() {
this.addComponent(new PolicyComponent());
this.addComponent(new DcaeComponent());
@@ -280,6 +287,14 @@ public class Loop implements Serializable {
this.components.put(component.getComponentName(), component);
}
+ public LoopTemplate getLoopTemplate() {
+ return loopTemplate;
+ }
+
+ public void setLoopTemplate(LoopTemplate loopTemplate) {
+ this.loopTemplate = loopTemplate;
+ }
+
/**
* Generate the loop name.
*
diff --git a/src/main/java/org/onap/clamp/loop/LoopService.java b/src/main/java/org/onap/clamp/loop/LoopService.java
index b18c38490..e52029662 100644
--- a/src/main/java/org/onap/clamp/loop/LoopService.java
+++ b/src/main/java/org/onap/clamp/loop/LoopService.java
@@ -31,29 +31,23 @@ import java.util.Set;
import javax.persistence.EntityNotFoundException;
import org.onap.clamp.policy.microservice.MicroServicePolicy;
-import org.onap.clamp.policy.microservice.MicroservicePolicyService;
+import org.onap.clamp.policy.microservice.MicroServicePolicyService;
import org.onap.clamp.policy.operational.OperationalPolicy;
import org.onap.clamp.policy.operational.OperationalPolicyService;
-import org.springframework.stereotype.Component;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
-@Component
public class LoopService {
- private final LoopsRepository loopsRepository;
- private final MicroservicePolicyService microservicePolicyService;
- private final OperationalPolicyService operationalPolicyService;
+ @Autowired
+ private LoopsRepository loopsRepository;
- /**
- * Constructor.
- */
- public LoopService(LoopsRepository loopsRepository, MicroservicePolicyService microservicePolicyService,
- OperationalPolicyService operationalPolicyService) {
- this.loopsRepository = loopsRepository;
- this.microservicePolicyService = microservicePolicyService;
- this.operationalPolicyService = operationalPolicyService;
- }
+ @Autowired
+ private MicroServicePolicyService microservicePolicyService;
+
+ @Autowired
+ private OperationalPolicyService operationalPolicyService;
Loop saveOrUpdateLoop(Loop loop) {
return loopsRepository.save(loop);
@@ -109,7 +103,7 @@ public class LoopService {
private Loop findClosedLoopByName(String loopName) {
return loopsRepository.findById(loopName)
- .orElseThrow(() -> new EntityNotFoundException("Couldn't find closed loop named: " + loopName));
+ .orElseThrow(() -> new EntityNotFoundException("Couldn't find closed loop named: " + loopName));
}
/**
diff --git a/src/main/java/org/onap/clamp/loop/LoopsRepository.java b/src/main/java/org/onap/clamp/loop/LoopsRepository.java
index 37c47622f..aaa49116f 100644
--- a/src/main/java/org/onap/clamp/loop/LoopsRepository.java
+++ b/src/main/java/org/onap/clamp/loop/LoopsRepository.java
@@ -24,12 +24,13 @@
package org.onap.clamp.loop;
import java.util.List;
+
+import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
-import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
@Repository
-public interface LoopsRepository extends CrudRepository<Loop, String> {
+public interface LoopsRepository extends JpaRepository<Loop, String> {
@Query("SELECT loop.name FROM Loop as loop")
List<String> getAllLoopNames();
diff --git a/src/main/java/org/onap/clamp/loop/common/AuditEntity.java b/src/main/java/org/onap/clamp/loop/common/AuditEntity.java
new file mode 100644
index 000000000..445f5b9e8
--- /dev/null
+++ b/src/main/java/org/onap/clamp/loop/common/AuditEntity.java
@@ -0,0 +1,108 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2020 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.loop.common;
+
+import com.google.gson.annotations.Expose;
+
+import java.time.Instant;
+import java.time.temporal.ChronoUnit;
+
+import javax.persistence.Column;
+import javax.persistence.EntityListeners;
+import javax.persistence.MappedSuperclass;
+
+import org.springframework.data.annotation.CreatedBy;
+import org.springframework.data.annotation.CreatedDate;
+import org.springframework.data.annotation.LastModifiedBy;
+import org.springframework.data.annotation.LastModifiedDate;
+import org.springframework.data.jpa.domain.support.AuditingEntityListener;
+
+@MappedSuperclass
+@EntityListeners(AuditingEntityListener.class)
+public class AuditEntity {
+
+ @Expose
+ @CreatedDate
+ @Column(name = "created_timestamp", nullable = false, updatable = false)
+ private Instant createdDate;
+
+ @Expose
+ @LastModifiedDate
+ @Column(name = "updated_timestamp", nullable = false)
+ private Instant updatedDate;
+
+ @Expose
+ @LastModifiedBy
+ @Column(name = "updated_by")
+ private String updatedBy;
+
+ @Expose
+ @CreatedBy
+ @Column(name = "created_by")
+ private String createdBy;
+
+ public Instant getCreatedDate() {
+ return createdDate;
+ }
+
+ public void setCreatedDate(Instant createdDate) {
+ if (createdDate != null) {
+ this.createdDate = createdDate.truncatedTo(ChronoUnit.SECONDS);
+ } else {
+ this.createdDate = null;
+ }
+ }
+
+ public Instant getUpdatedDate() {
+ return updatedDate;
+ }
+
+ public void setUpdatedDate(Instant updatedDate) {
+ if (updatedDate != null) {
+ this.updatedDate = updatedDate.truncatedTo(ChronoUnit.SECONDS);
+ } else {
+ this.updatedDate = null;
+ }
+ }
+
+ public String getUpdatedBy() {
+ return updatedBy;
+ }
+
+ public void setUpdatedBy(String updatedBy) {
+ this.updatedBy = updatedBy;
+ }
+
+ public String getCreatedBy() {
+ return createdBy;
+ }
+
+ public void setCreatedBy(String createdBy) {
+ this.createdBy = createdBy;
+ }
+
+ public AuditEntity() {
+ }
+
+}
diff --git a/src/main/java/org/onap/clamp/loop/log/LoopLog.java b/src/main/java/org/onap/clamp/loop/log/LoopLog.java
index 0e1153a32..e49598879 100644
--- a/src/main/java/org/onap/clamp/loop/log/LoopLog.java
+++ b/src/main/java/org/onap/clamp/loop/log/LoopLog.java
@@ -190,9 +190,7 @@ public class LoopLog implements Serializable, Comparable<LoopLog> {
if (arg0.getId() == null) {
return -1;
}
-
return arg0.getId().compareTo(this.getId());
-
}
}
diff --git a/src/main/java/org/onap/clamp/loop/log/LoopLogRepository.java b/src/main/java/org/onap/clamp/loop/log/LoopLogRepository.java
index 103341fa5..0b3c34ec0 100644
--- a/src/main/java/org/onap/clamp/loop/log/LoopLogRepository.java
+++ b/src/main/java/org/onap/clamp/loop/log/LoopLogRepository.java
@@ -23,10 +23,10 @@
package org.onap.clamp.loop.log;
-import org.springframework.data.repository.CrudRepository;
+import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
-public interface LoopLogRepository extends CrudRepository<LoopLog, Long> {
+public interface LoopLogRepository extends JpaRepository<LoopLog, Long> {
}
diff --git a/src/main/java/org/onap/clamp/loop/service/Service.java b/src/main/java/org/onap/clamp/loop/service/Service.java
index 115f9f768..b74ee0b0d 100644
--- a/src/main/java/org/onap/clamp/loop/service/Service.java
+++ b/src/main/java/org/onap/clamp/loop/service/Service.java
@@ -39,9 +39,9 @@ import javax.persistence.Transient;
import org.hibernate.annotations.Type;
import org.hibernate.annotations.TypeDef;
import org.hibernate.annotations.TypeDefs;
+import org.onap.clamp.clds.util.JsonUtils;
import org.onap.clamp.dao.model.jsontype.StringJsonUserType;
-
@Entity
@Table(name = "services")
@TypeDefs({ @TypeDef(name = "json", typeClass = StringJsonUserType.class) })
@@ -76,13 +76,25 @@ public class Service implements Serializable {
private JsonObject resourceDetails;
/**
- * Public constructor.
+ * Default constructor for serialization.
*/
public Service() {
}
/**
- * Constructor.
+ * Constructor with string.
+ */
+ public Service(String serviceDetails, String resourceDetails) {
+ JsonObject serviceDetailsJson = JsonUtils.GSON.fromJson(serviceDetails, JsonObject.class);
+ JsonObject resourceDetailsJson = JsonUtils.GSON.fromJson(resourceDetails, JsonObject.class);
+ this.name = serviceDetailsJson.get("name").getAsString();
+ this.serviceUuid = serviceDetailsJson.get("UUID").getAsString();
+ this.serviceDetails = serviceDetailsJson;
+ this.resourceDetails = resourceDetailsJson;
+ }
+
+ /**
+ * Constructor with Json Object.
*/
public Service(JsonObject serviceDetails, JsonObject resourceDetails, String version) {
this.name = serviceDetails.get("name").getAsString();
diff --git a/src/main/java/org/onap/clamp/loop/service/ServicesRepository.java b/src/main/java/org/onap/clamp/loop/service/ServicesRepository.java
new file mode 100644
index 000000000..fe5ba8ed0
--- /dev/null
+++ b/src/main/java/org/onap/clamp/loop/service/ServicesRepository.java
@@ -0,0 +1,31 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2020 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.loop.service;
+
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface ServicesRepository extends JpaRepository<Service, String> {
+}
diff --git a/src/main/java/org/onap/clamp/loop/template/LoopTemplate.java b/src/main/java/org/onap/clamp/loop/template/LoopTemplate.java
new file mode 100644
index 000000000..10367e77d
--- /dev/null
+++ b/src/main/java/org/onap/clamp/loop/template/LoopTemplate.java
@@ -0,0 +1,268 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.loop.template;
+
+import com.google.gson.annotations.Expose;
+
+import java.io.Serializable;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+
+import org.hibernate.annotations.SortNatural;
+import org.onap.clamp.loop.common.AuditEntity;
+import org.onap.clamp.loop.service.Service;
+
+@Entity
+@Table(name = "loop_templates")
+public class LoopTemplate extends AuditEntity implements Serializable {
+
+ /**
+ * The serial version id.
+ */
+ private static final long serialVersionUID = -286522707701388642L;
+
+ @Id
+ @Expose
+ @Column(nullable = false, name = "name", unique = true)
+ private String name;
+
+ /**
+ * This field is used when we have a blueprint defining all microservices. The
+ * other option would be to have independent blueprint for each microservices.
+ * In that case they are stored in each MicroServiceModel
+ */
+ @Column(columnDefinition = "MEDIUMTEXT", nullable = false, name = "blueprint_yaml")
+ private String blueprint;
+
+ @Expose
+ @Column(columnDefinition = "MEDIUMTEXT", name = "svg_representation")
+ private String svgRepresentation;
+
+ @Expose
+ @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "loopTemplate", orphanRemoval = true)
+ @SortNatural
+ private SortedSet<TemplateMicroServiceModel> microServiceModelUsed = new TreeSet<>();
+
+ @Expose
+ @ManyToOne(fetch = FetchType.EAGER, cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH })
+ @JoinColumn(name = "service_uuid")
+ private Service modelService;
+
+ @Expose
+ @Column(name = "maximum_instances_allowed")
+ private Integer maximumInstancesAllowed;
+
+ /**
+ * name getter.
+ *
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * name setter.
+ *
+ * @param name the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * blueprint getter.
+ *
+ * @return the blueprint
+ */
+ public String getBlueprint() {
+ return blueprint;
+ }
+
+ /**
+ * blueprint setter.
+ *
+ * @param blueprint the blueprint to set
+ */
+ public void setBlueprint(String blueprint) {
+ this.blueprint = blueprint;
+ }
+
+ /**
+ * svgRepresentation getter.
+ *
+ * @return the svgRepresentation
+ */
+ public String getSvgRepresentation() {
+ return svgRepresentation;
+ }
+
+ /**
+ * svgRepresentation setter.
+ *
+ * @param svgRepresentation the svgRepresentation to set
+ */
+ public void setSvgRepresentation(String svgRepresentation) {
+ this.svgRepresentation = svgRepresentation;
+ }
+
+ /**
+ * microServiceModelUsed getter.
+ *
+ * @return the microServiceModelUsed
+ */
+ public SortedSet<TemplateMicroServiceModel> getMicroServiceModelUsed() {
+ return microServiceModelUsed;
+ }
+
+ /**
+ * maximumInstancesAllowed getter.
+ *
+ * @return the maximumInstancesAllowed
+ */
+ public Integer getMaximumInstancesAllowed() {
+ return maximumInstancesAllowed;
+ }
+
+ /**
+ * maximumInstancesAllowed setter.
+ *
+ * @param maximumInstancesAllowed the maximumInstancesAllowed to set
+ */
+ public void setMaximumInstancesAllowed(Integer maximumInstancesAllowed) {
+ this.maximumInstancesAllowed = maximumInstancesAllowed;
+ }
+
+ /**
+ * Add a microService model to the current template, the microservice is added
+ * at the end of the list so the flowOrder is computed automatically.
+ *
+ * @param microServiceModel The microserviceModel to add
+ */
+ public void addMicroServiceModel(MicroServiceModel microServiceModel) {
+ TemplateMicroServiceModel jointEntry = new TemplateMicroServiceModel(this, microServiceModel,
+ this.microServiceModelUsed.size());
+ this.microServiceModelUsed.add(jointEntry);
+ microServiceModel.getUsedByLoopTemplates().add(jointEntry);
+ }
+
+ /**
+ * Add a microService model to the current template, the flow order must be
+ * specified manually.
+ *
+ * @param microServiceModel The microserviceModel to add
+ * @param listPosition The position in the flow
+ */
+ public void addMicroServiceModel(MicroServiceModel microServiceModel, Integer listPosition) {
+ TemplateMicroServiceModel jointEntry = new TemplateMicroServiceModel(this, microServiceModel, listPosition);
+ this.microServiceModelUsed.add(jointEntry);
+ microServiceModel.getUsedByLoopTemplates().add(jointEntry);
+ }
+
+ /**
+ * modelService getter.
+ *
+ * @return the modelService
+ */
+ public Service getModelService() {
+ return modelService;
+ }
+
+ /**
+ * modelService setter.
+ *
+ * @param modelService the modelService to set
+ */
+ public void setModelService(Service modelService) {
+ this.modelService = modelService;
+ }
+
+ /**
+ * Default constructor for serialization.
+ */
+ public LoopTemplate() {
+
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param name The loop template name id
+ * @param blueprint The blueprint containing all microservices (legacy
+ * case)
+ * @param svgRepresentation The svg representation of that loop template
+ * @param maxInstancesAllowed The maximum number of instances that can be
+ * created from that template
+ * @param service The service associated to that loop template
+ */
+ public LoopTemplate(String name, String blueprint, String svgRepresentation, Integer maxInstancesAllowed,
+ Service service) {
+ this.name = name;
+ this.blueprint = blueprint;
+ this.svgRepresentation = svgRepresentation;
+
+ this.maximumInstancesAllowed = maxInstancesAllowed;
+ this.modelService = service;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ LoopTemplate other = (LoopTemplate) obj;
+ if (name == null) {
+ if (other.name != null) {
+ return false;
+ }
+ } else if (!name.equals(other.name)) {
+ return false;
+ }
+ return true;
+ }
+}
diff --git a/src/main/java/org/onap/clamp/loop/template/LoopTemplatesRepository.java b/src/main/java/org/onap/clamp/loop/template/LoopTemplatesRepository.java
new file mode 100644
index 000000000..07f304de7
--- /dev/null
+++ b/src/main/java/org/onap/clamp/loop/template/LoopTemplatesRepository.java
@@ -0,0 +1,37 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.loop.template;
+
+import java.util.List;
+
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface LoopTemplatesRepository extends JpaRepository<LoopTemplate, String> {
+
+ @Query("SELECT looptemplate.name FROM LoopTemplate as looptemplate")
+ List<String> getAllLoopTemplateNames();
+}
diff --git a/src/main/java/org/onap/clamp/loop/template/MicroServiceModel.java b/src/main/java/org/onap/clamp/loop/template/MicroServiceModel.java
new file mode 100644
index 000000000..1e2b140e7
--- /dev/null
+++ b/src/main/java/org/onap/clamp/loop/template/MicroServiceModel.java
@@ -0,0 +1,217 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.loop.template;
+
+import com.google.gson.annotations.Expose;
+
+import java.io.Serializable;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.JoinColumns;
+import javax.persistence.ManyToOne;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+
+import org.onap.clamp.loop.common.AuditEntity;
+
+/**
+ * This class represents a micro service model for a loop template.
+ */
+
+@Entity
+@Table(name = "micro_service_models")
+public class MicroServiceModel extends AuditEntity implements Serializable {
+
+ /**
+ * The serial version id.
+ */
+ private static final long serialVersionUID = -286522707701376645L;
+
+ @Id
+ @Expose
+ @Column(nullable = false, name = "name", unique = true)
+ private String name;
+
+ /**
+ * This variable is used to store the type mentioned in the micro-service
+ * blueprint.
+ */
+ @Expose
+ @Column(nullable = false, name = "policy_type")
+ private String policyType;
+
+ @Column(nullable = false, name = "blueprint_yaml")
+ private String blueprint;
+
+ @Expose
+ @ManyToOne(fetch = FetchType.EAGER, cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH })
+ @JoinColumns({ @JoinColumn(name = "policy_model_type", referencedColumnName = "policy_model_type"),
+ @JoinColumn(name = "policy_model_version", referencedColumnName = "version") })
+ private PolicyModel policyModel;
+
+ @OneToMany(fetch = FetchType.LAZY, mappedBy = "microServiceModel", orphanRemoval = true)
+ private Set<TemplateMicroServiceModel> usedByLoopTemplates = new HashSet<>();
+
+ /**
+ * policyModel getter.
+ *
+ * @return the policyModel
+ */
+ public PolicyModel getPolicyModel() {
+ return policyModel;
+ }
+
+ /**
+ * policyModel setter.
+ *
+ * @param policyModel the policyModel to set
+ */
+ public void setPolicyModel(PolicyModel policyModel) {
+ this.policyModel = policyModel;
+ }
+
+ /**
+ * name getter.
+ *
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * name setter.
+ *
+ * @param name the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * policyType getter.
+ *
+ * @return the policyType
+ */
+ public String getPolicyType() {
+ return policyType;
+ }
+
+ /**
+ * policyType setter.
+ *
+ * @param policyType the policyType to set
+ */
+ public void setPolicyType(String policyType) {
+ this.policyType = policyType;
+ }
+
+ /**
+ * blueprint getter.
+ *
+ * @return the blueprint
+ */
+ public String getBlueprint() {
+ return blueprint;
+ }
+
+ /**
+ * blueprint setter.
+ *
+ * @param blueprint the blueprint to set
+ */
+ public void setBlueprint(String blueprint) {
+ this.blueprint = blueprint;
+ }
+
+ /**
+ * usedByLoopTemplates getter.
+ *
+ * @return the usedByLoopTemplates
+ */
+ public Set<TemplateMicroServiceModel> getUsedByLoopTemplates() {
+ return usedByLoopTemplates;
+ }
+
+ /**
+ * Default constructor for serialization.
+ */
+ public MicroServiceModel() {
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param name The name id
+ * @param policyType The policy model type like
+ * onap.policies.controlloop.operational.common.Apex
+ * @param blueprint The blueprint defined for dcae that contains the policy
+ * type to use
+ * @param policyModel The policy model for the policy type mentioned here
+ */
+ public MicroServiceModel(String name, String policyType, String blueprint, PolicyModel policyModel) {
+ this.name = name;
+ this.policyType = policyType;
+ this.blueprint = blueprint;
+ this.policyModel = policyModel;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ MicroServiceModel other = (MicroServiceModel) obj;
+ if (name == null) {
+ if (other.name != null) {
+ return false;
+ }
+ } else if (!name.equals(other.name)) {
+ return false;
+ }
+ return true;
+ }
+
+}
diff --git a/src/main/java/org/onap/clamp/loop/template/MicroServiceModelsRepository.java b/src/main/java/org/onap/clamp/loop/template/MicroServiceModelsRepository.java
new file mode 100644
index 000000000..2b1870485
--- /dev/null
+++ b/src/main/java/org/onap/clamp/loop/template/MicroServiceModelsRepository.java
@@ -0,0 +1,31 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.loop.template;
+
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface MicroServiceModelsRepository extends JpaRepository<MicroServiceModel, String> {
+}
diff --git a/src/main/java/org/onap/clamp/loop/template/PolicyModel.java b/src/main/java/org/onap/clamp/loop/template/PolicyModel.java
new file mode 100644
index 000000000..e6580beed
--- /dev/null
+++ b/src/main/java/org/onap/clamp/loop/template/PolicyModel.java
@@ -0,0 +1,239 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.loop.template;
+
+import com.google.gson.annotations.Expose;
+
+import java.io.Serializable;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.IdClass;
+import javax.persistence.Table;
+
+import org.onap.clamp.loop.common.AuditEntity;
+import org.onap.clamp.util.SemanticVersioning;
+
+/**
+ * This class represents the policy model tosca revision that we can have to a
+ * specific microservice.
+ */
+@Entity
+@Table(name = "policy_models")
+@IdClass(PolicyModelId.class)
+public class PolicyModel extends AuditEntity implements Serializable, Comparable<PolicyModel> {
+
+ /**
+ * The serial version id.
+ */
+ private static final long serialVersionUID = -286522705701376645L;
+
+ /**
+ * This variable is used to store the type mentioned in the micro-service
+ * blueprint.
+ */
+ @Id
+ @Expose
+ @Column(nullable = false, name = "policy_model_type")
+ private String policyModelType;
+
+ /**
+ * Semantic versioning on policy side.
+ */
+ @Id
+ @Expose
+ @Column(name = "version")
+ private String version;
+
+ @Column(columnDefinition = "MEDIUMTEXT", name = "policy_tosca")
+ private String policyModelTosca;
+
+ @Expose
+ @Column(name = "policy_acronym")
+ private String policyAcronym;
+
+ @Expose
+ @Column(name = "policy_variant")
+ private String policyVariant;
+
+ /**
+ * policyModelTosca getter.
+ *
+ * @return the policyModelTosca
+ */
+ public String getPolicyModelTosca() {
+ return policyModelTosca;
+ }
+
+ /**
+ * policyModelTosca setter.
+ *
+ * @param policyModelTosca the policyModelTosca to set
+ */
+ public void setPolicyModelTosca(String policyModelTosca) {
+ this.policyModelTosca = policyModelTosca;
+ }
+
+ /**
+ * policyModelType getter.
+ *
+ * @return the modelType
+ */
+ public String getPolicyModelType() {
+ return policyModelType;
+ }
+
+ /**
+ * policyModelType setter.
+ *
+ * @param modelType the modelType to set
+ */
+ public void setPolicyModelType(String modelType) {
+ this.policyModelType = modelType;
+ }
+
+ /**
+ * version getter.
+ *
+ * @return the version
+ */
+ public String getVersion() {
+ return version;
+ }
+
+ /**
+ * version setter.
+ *
+ * @param version the version to set
+ */
+ public void setVersion(String version) {
+ // Try to convert it before
+ this.version = version;
+ }
+
+ /**
+ * policyAcronym getter.
+ *
+ * @return the policyAcronym value
+ */
+ public String getPolicyAcronym() {
+ return policyAcronym;
+ }
+
+ /**
+ * policyAcronym setter.
+ *
+ * @param policyAcronym The policyAcronym to set
+ */
+ public void setPolicyAcronym(String policyAcronym) {
+ this.policyAcronym = policyAcronym;
+ }
+
+ /**
+ * policyVariant getter.
+ *
+ * @return the policyVariant value
+ */
+ public String getPolicyVariant() {
+ return policyVariant;
+ }
+
+ /**
+ * policyVariant setter.
+ *
+ * @param policyVariant The policyVariant to set
+ */
+ public void setPolicyVariant(String policyVariant) {
+ this.policyVariant = policyVariant;
+ }
+
+ /**
+ * Default constructor for serialization.
+ */
+ public PolicyModel() {
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param policyType The policyType (referenced in the blueprint)
+ * @param policyModelTosca The policy tosca model in yaml
+ * @param version the version like 1.0.0
+ * @param policyAcronym Short policy name if it exists
+ * @param policyVariant Subtype for policy if it exists (could be used by UI)
+ */
+ public PolicyModel(String policyType, String policyModelTosca, String version, String policyAcronym,
+ String policyVariant) {
+ this.policyModelType = policyType;
+ this.policyModelTosca = policyModelTosca;
+ this.version = version;
+ this.policyAcronym = policyAcronym;
+ this.policyVariant = policyVariant;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((policyModelType == null) ? 0 : policyModelType.hashCode());
+ result = prime * result + ((version == null) ? 0 : version.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ PolicyModel other = (PolicyModel) obj;
+ if (policyModelType == null) {
+ if (other.policyModelType != null) {
+ return false;
+ }
+ } else if (!policyModelType.equals(other.policyModelType)) {
+ return false;
+ }
+ if (version == null) {
+ if (other.version != null) {
+ return false;
+ }
+ } else if (!version.equals(other.version)) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public int compareTo(PolicyModel arg0) {
+ // Reverse it, so that by default we have the latest
+ return SemanticVersioning.compare(arg0.getVersion(), this.version);
+ }
+}
diff --git a/src/main/java/org/onap/clamp/loop/template/PolicyModelId.java b/src/main/java/org/onap/clamp/loop/template/PolicyModelId.java
new file mode 100644
index 000000000..c4dd1933b
--- /dev/null
+++ b/src/main/java/org/onap/clamp/loop/template/PolicyModelId.java
@@ -0,0 +1,93 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.loop.template;
+
+import com.google.gson.annotations.Expose;
+
+import java.io.Serializable;
+
+public class PolicyModelId implements Serializable {
+
+ /**
+ * Serial Id.
+ */
+ private static final long serialVersionUID = -2846526482064334745L;
+
+ @Expose
+ private String policyModelType;
+
+ @Expose
+ private String version;
+
+ /**
+ * Default constructor for serialization.
+ */
+ public PolicyModelId() {
+
+ }
+
+ /**
+ * Constructor.
+ */
+ public PolicyModelId(String policyModelType, String version) {
+ this.policyModelType = policyModelType;
+ this.version = version;
+ }
+
+ /**
+ * policyModelType getter.
+ *
+ * @return the policyModelType
+ */
+ public String getPolicyModelType() {
+ return policyModelType;
+ }
+
+ /**
+ * policyModelType setter.
+ *
+ * @param policyModelType the policyModelType to set
+ */
+ public void setPolicyModelType(String policyModelType) {
+ this.policyModelType = policyModelType;
+ }
+
+ /**
+ * version getter.
+ *
+ * @return the version
+ */
+ public String getVersion() {
+ return version;
+ }
+
+ /**
+ * version setter.
+ *
+ * @param version the version to set
+ */
+ public void setVersion(String version) {
+ this.version = version;
+ }
+}
diff --git a/src/main/java/org/onap/clamp/loop/template/PolicyModelsRepository.java b/src/main/java/org/onap/clamp/loop/template/PolicyModelsRepository.java
new file mode 100644
index 000000000..a76e386b5
--- /dev/null
+++ b/src/main/java/org/onap/clamp/loop/template/PolicyModelsRepository.java
@@ -0,0 +1,38 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.loop.template;
+
+import java.util.List;
+
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface PolicyModelsRepository extends JpaRepository<PolicyModel, PolicyModelId> {
+ @Query("SELECT policymodel.policyModelType FROM PolicyModel as policymodel")
+ List<String> getAllPolicyModelType();
+
+ List<PolicyModel> findByPolicyModelType(String policyModelType);
+}
diff --git a/src/main/java/org/onap/clamp/loop/template/PolicyModelsService.java b/src/main/java/org/onap/clamp/loop/template/PolicyModelsService.java
new file mode 100644
index 000000000..8e22852a9
--- /dev/null
+++ b/src/main/java/org/onap/clamp/loop/template/PolicyModelsService.java
@@ -0,0 +1,59 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.loop.template;
+
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class PolicyModelsService {
+ private final PolicyModelsRepository policyModelsRepository;
+
+ @Autowired
+ public PolicyModelsService(PolicyModelsRepository policyModelrepo) {
+ policyModelsRepository = policyModelrepo;
+ }
+
+ public PolicyModel saveOrUpdatePolicyModel(PolicyModel policyModel) {
+ return policyModelsRepository.save(policyModel);
+ }
+
+ public List<String> getAllPolicyModelTypes() {
+ return policyModelsRepository.getAllPolicyModelType();
+ }
+
+ public Iterable<PolicyModel> getAllPolicyModels() {
+ return policyModelsRepository.findAll();
+ }
+
+ public PolicyModel getPolicyModel(String type, String version) {
+ return policyModelsRepository.findById(new PolicyModelId(type, version)).orElse(null);
+ }
+
+ public Iterable<PolicyModel> getAllPolicyModelsByType(String type) {
+ return policyModelsRepository.findByPolicyModelType(type);
+ }
+}
diff --git a/src/main/java/org/onap/clamp/loop/template/TemplateMicroServiceModel.java b/src/main/java/org/onap/clamp/loop/template/TemplateMicroServiceModel.java
new file mode 100644
index 000000000..7547c1f70
--- /dev/null
+++ b/src/main/java/org/onap/clamp/loop/template/TemplateMicroServiceModel.java
@@ -0,0 +1,194 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.loop.template;
+
+import com.google.gson.annotations.Expose;
+
+import java.io.Serializable;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.EmbeddedId;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.MapsId;
+import javax.persistence.Table;
+
+@Entity
+@Table(name = "templates_microservicemodels")
+public class TemplateMicroServiceModel implements Serializable, Comparable<TemplateMicroServiceModel> {
+
+ /**
+ * Serial ID.
+ */
+ private static final long serialVersionUID = 5924989899078094245L;
+
+ @EmbeddedId
+ private TemplateMicroServiceModelId templateMicroServiceModelId;
+
+ @ManyToOne(fetch = FetchType.LAZY)
+ @MapsId("loopTemplateName")
+ @JoinColumn(name = "loop_template_name")
+ private LoopTemplate loopTemplate;
+
+ @Expose
+ @ManyToOne(fetch = FetchType.EAGER, cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH })
+ @MapsId("microServiceModelName")
+ @JoinColumn(name = "micro_service_model_name")
+ private MicroServiceModel microServiceModel;
+
+ @Expose
+ @Column(nullable = false, name = "flow_order")
+ private Integer flowOrder;
+
+ /**
+ * Default constructor for serialization.
+ */
+ public TemplateMicroServiceModel() {
+
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param loopTemplate The loop template object
+ * @param microServiceModel The microServiceModel object
+ * @param flowOrder The position of the micro service in the flow
+ */
+ public TemplateMicroServiceModel(LoopTemplate loopTemplate, MicroServiceModel microServiceModel,
+ Integer flowOrder) {
+ this.loopTemplate = loopTemplate;
+ this.microServiceModel = microServiceModel;
+ this.flowOrder = flowOrder;
+ this.templateMicroServiceModelId = new TemplateMicroServiceModelId(loopTemplate.getName(),
+ microServiceModel.getName());
+ }
+
+ /**
+ * loopTemplate getter.
+ *
+ * @return the loopTemplate
+ */
+ public LoopTemplate getLoopTemplate() {
+ return loopTemplate;
+ }
+
+ /**
+ * loopTemplate setter.
+ *
+ * @param loopTemplate the loopTemplate to set
+ */
+ public void setLoopTemplate(LoopTemplate loopTemplate) {
+ this.loopTemplate = loopTemplate;
+ }
+
+ /**
+ * microServiceModel getter.
+ *
+ * @return the microServiceModel
+ */
+ public MicroServiceModel getMicroServiceModel() {
+ return microServiceModel;
+ }
+
+ /**
+ * microServiceModel setter.
+ *
+ * @param microServiceModel the microServiceModel to set
+ */
+ public void setMicroServiceModel(MicroServiceModel microServiceModel) {
+ this.microServiceModel = microServiceModel;
+ }
+
+ /**
+ * flowOrder getter.
+ *
+ * @return the flowOrder
+ */
+ public Integer getFlowOrder() {
+ return flowOrder;
+ }
+
+ /**
+ * flowOrder setter.
+ *
+ * @param flowOrder the flowOrder to set
+ */
+ public void setFlowOrder(Integer flowOrder) {
+ this.flowOrder = flowOrder;
+ }
+
+ @Override
+ public int compareTo(TemplateMicroServiceModel arg0) {
+ // Reverse it, so that by default we have the latest
+ if (getFlowOrder() == null) {
+ return 1;
+ }
+ if (arg0.getFlowOrder() == null) {
+ return -1;
+ }
+ return arg0.getFlowOrder().compareTo(this.getFlowOrder());
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((loopTemplate == null) ? 0 : loopTemplate.hashCode());
+ result = prime * result + ((microServiceModel == null) ? 0 : microServiceModel.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ TemplateMicroServiceModel other = (TemplateMicroServiceModel) obj;
+ if (loopTemplate == null) {
+ if (other.loopTemplate != null) {
+ return false;
+ }
+ } else if (!loopTemplate.equals(other.loopTemplate)) {
+ return false;
+ }
+ if (microServiceModel == null) {
+ if (other.microServiceModel != null) {
+ return false;
+ }
+ } else if (!microServiceModel.equals(other.microServiceModel)) {
+ return false;
+ }
+ return true;
+ }
+
+}
diff --git a/src/main/java/org/onap/clamp/loop/template/TemplateMicroServiceModelId.java b/src/main/java/org/onap/clamp/loop/template/TemplateMicroServiceModelId.java
new file mode 100644
index 000000000..74c768974
--- /dev/null
+++ b/src/main/java/org/onap/clamp/loop/template/TemplateMicroServiceModelId.java
@@ -0,0 +1,102 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.loop.template;
+
+import com.google.gson.annotations.Expose;
+
+import java.io.Serializable;
+
+import javax.persistence.Column;
+import javax.persistence.Embeddable;
+
+@Embeddable
+public class TemplateMicroServiceModelId implements Serializable {
+
+ /**
+ * Serial ID.
+ */
+ private static final long serialVersionUID = 4089888115504914773L;
+
+ @Expose
+ @Column(name = "loop_template_name")
+ private String loopTemplateName;
+
+ @Expose
+ @Column(name = "micro_service_model_name")
+ private String microServiceModelName;
+
+ /**
+ * Default constructor for serialization.
+ */
+ public TemplateMicroServiceModelId() {
+
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param loopTemplateName The loop template name id
+ * @param microServiceModelName THe micro Service name id
+ */
+ public TemplateMicroServiceModelId(String loopTemplateName, String microServiceModelName) {
+ this.loopTemplateName = loopTemplateName;
+ this.microServiceModelName = microServiceModelName;
+ }
+
+ /**
+ * loopTemplateName getter.
+ *
+ * @return the loopTemplateName
+ */
+ public String getLoopTemplateName() {
+ return loopTemplateName;
+ }
+
+ /**
+ * loopTemplateName setter.
+ *
+ * @param loopTemplateName the loopTemplateName to set
+ */
+ public void setLoopTemplateName(String loopTemplateName) {
+ this.loopTemplateName = loopTemplateName;
+ }
+
+ /**
+ * microServiceModelName getter.
+ *
+ * @return the microServiceModelName
+ */
+ public String getMicroServiceModelName() {
+ return microServiceModelName;
+ }
+
+ /**
+ * microServiceModelName setter.
+ *
+ * @param microServiceModelName the microServiceModelName to set
+ */
+ public void setMicroServiceModelName(String microServiceModelName) {
+ this.microServiceModelName = microServiceModelName;
+ }
+}
diff --git a/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java b/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java
index 2943c39a2..98742d22b 100644
--- a/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java
+++ b/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java
@@ -40,7 +40,9 @@ import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
+import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
+import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;
@@ -52,13 +54,15 @@ import org.onap.clamp.clds.tosca.ToscaYamlToJsonConvertor;
import org.onap.clamp.clds.util.JsonUtils;
import org.onap.clamp.dao.model.jsontype.StringJsonUserType;
import org.onap.clamp.loop.Loop;
+import org.onap.clamp.loop.common.AuditEntity;
+import org.onap.clamp.loop.template.MicroServiceModel;
import org.onap.clamp.policy.Policy;
import org.yaml.snakeyaml.Yaml;
@Entity
@Table(name = "micro_service_policies")
@TypeDefs({ @TypeDef(name = "json", typeClass = StringJsonUserType.class) })
-public class MicroServicePolicy implements Serializable, Policy {
+public class MicroServicePolicy extends AuditEntity implements Serializable, Policy {
/**
* The serial version ID.
*/
@@ -73,10 +77,18 @@ public class MicroServicePolicy implements Serializable, Policy {
private String name;
@Expose
- @Column(nullable = false, name = "model_type")
+ @Column(nullable = false, name = "policy_model_type")
private String modelType;
@Expose
+ @Column(name = "context")
+ private String context;
+
+ @Expose
+ @Column(name = "device_type_scope")
+ private String deviceTypeScope;
+
+ @Expose
@Type(type = "json")
@Column(columnDefinition = "json", name = "properties")
private JsonObject properties;
@@ -96,6 +108,11 @@ public class MicroServicePolicy implements Serializable, Policy {
@ManyToMany(mappedBy = "microServicePolicies", fetch = FetchType.EAGER)
private Set<Loop> usedByLoops = new HashSet<>();
+ @Expose
+ @ManyToOne(fetch = FetchType.EAGER)
+ @JoinColumn(name = "micro_service_model_id")
+ private MicroServiceModel microServiceModel;
+
public MicroServicePolicy() {
// serialization
}
@@ -203,6 +220,49 @@ public class MicroServicePolicy implements Serializable, Policy {
this.usedByLoops = usedBy;
}
+ public String getContext() {
+ return context;
+ }
+
+ public void setContext(String context) {
+ this.context = context;
+ }
+
+ public String getDeviceTypeScope() {
+ return deviceTypeScope;
+ }
+
+ public void setDeviceTypeScope(String deviceTypeScope) {
+ this.deviceTypeScope = deviceTypeScope;
+ }
+
+ /**
+ * microServiceModel getter.
+ *
+ * @return the microServiceModel
+ */
+ public MicroServiceModel getMicroServiceModel() {
+ return microServiceModel;
+ }
+
+ /**
+ * microServiceModel setter.
+ *
+ * @param microServiceModel the microServiceModel to set
+ */
+ public void setMicroServiceModel(MicroServiceModel microServiceModel) {
+ this.microServiceModel = microServiceModel;
+ }
+
+ /**
+ * name setter.
+ *
+ * @param name the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
@Override
public int hashCode() {
final int prime = 31;
diff --git a/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicyRepository.java b/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicyRepository.java
index f658aacc3..38b310ce8 100644
--- a/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicyRepository.java
+++ b/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicyRepository.java
@@ -23,10 +23,10 @@
package org.onap.clamp.policy.microservice;
-import org.springframework.data.repository.CrudRepository;
+import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
-interface MicroServicePolicyRepository extends CrudRepository<MicroServicePolicy, String> {
+public interface MicroServicePolicyRepository extends JpaRepository<MicroServicePolicy, String> {
}
diff --git a/src/main/java/org/onap/clamp/policy/microservice/MicroservicePolicyService.java b/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicyService.java
index 59ddaa009..346cdf624 100644
--- a/src/main/java/org/onap/clamp/policy/microservice/MicroservicePolicyService.java
+++ b/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicyService.java
@@ -35,12 +35,12 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
-public class MicroservicePolicyService implements PolicyService<MicroServicePolicy> {
+public class MicroServicePolicyService implements PolicyService<MicroServicePolicy> {
private final MicroServicePolicyRepository repository;
@Autowired
- public MicroservicePolicyService(MicroServicePolicyRepository repository) {
+ public MicroServicePolicyService(MicroServicePolicyRepository repository) {
this.repository = repository;
}
diff --git a/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java b/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java
index df7e27bf3..d9e8a57d6 100644
--- a/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java
+++ b/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java
@@ -46,6 +46,7 @@ import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
+import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;
@@ -55,6 +56,7 @@ import org.hibernate.annotations.TypeDef;
import org.hibernate.annotations.TypeDefs;
import org.onap.clamp.dao.model.jsontype.StringJsonUserType;
import org.onap.clamp.loop.Loop;
+import org.onap.clamp.loop.template.PolicyModel;
import org.onap.clamp.policy.Policy;
import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.Yaml;
@@ -90,6 +92,12 @@ public class OperationalPolicy implements Serializable, Policy {
@JoinColumn(name = "loop_id", nullable = false)
private Loop loop;
+ @Expose
+ @ManyToOne(fetch = FetchType.EAGER)
+ @JoinColumns({ @JoinColumn(name = "policy_model_type", referencedColumnName = "policy_model_type"),
+ @JoinColumn(name = "policy_model_version", referencedColumnName = "version") })
+ private PolicyModel policyModel;
+
public OperationalPolicy() {
// Serialization
}
@@ -137,6 +145,33 @@ public class OperationalPolicy implements Serializable, Policy {
this.configurationsJson = configurationsJson;
}
+ /**
+ * policyModel getter.
+ *
+ * @return the policyModel
+ */
+ public PolicyModel getPolicyModel() {
+ return policyModel;
+ }
+
+ /**
+ * policyModel setter.
+ *
+ * @param policyModel the policyModel to set
+ */
+ public void setPolicyModel(PolicyModel policyModel) {
+ this.policyModel = policyModel;
+ }
+
+ /**
+ * name setter.
+ *
+ * @param name the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
@Override
public JsonObject getJsonRepresentation() {
return jsonRepresentation;
diff --git a/src/main/java/org/onap/clamp/policy/operational/OperationalPolicyRepository.java b/src/main/java/org/onap/clamp/policy/operational/OperationalPolicyRepository.java
index 97b183f72..c0a6e12cd 100644
--- a/src/main/java/org/onap/clamp/policy/operational/OperationalPolicyRepository.java
+++ b/src/main/java/org/onap/clamp/policy/operational/OperationalPolicyRepository.java
@@ -23,10 +23,10 @@
package org.onap.clamp.policy.operational;
-import org.springframework.data.repository.CrudRepository;
+import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
-interface OperationalPolicyRepository extends CrudRepository<OperationalPolicy, String> {
+public interface OperationalPolicyRepository extends JpaRepository<OperationalPolicy, String> {
void deleteByName(String policyName);
}
diff --git a/src/main/java/org/onap/clamp/tosca/Dictionary.java b/src/main/java/org/onap/clamp/tosca/Dictionary.java
new file mode 100644
index 000000000..7b4e513a2
--- /dev/null
+++ b/src/main/java/org/onap/clamp/tosca/Dictionary.java
@@ -0,0 +1,174 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.tosca;
+
+import com.google.gson.annotations.Expose;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+
+import org.onap.clamp.loop.common.AuditEntity;
+
+/**
+ * Represents Dictionary.
+ */
+
+@Entity
+@Table(name = "dictionary")
+public class Dictionary extends AuditEntity implements Serializable {
+
+ /**
+ * The serial version id.
+ */
+ private static final long serialVersionUID = -286522707701388645L;
+
+ @Id
+ @Expose
+ @Column(nullable = false, name = "name", unique = true)
+ private String name;
+
+ @Expose
+ @Column(name = "dictionary_second_level")
+ private int secondLevelDictionary;
+
+ @Expose
+ @Column(name = "dictionary_type")
+ private String subDictionaryType;
+
+ @Expose
+ @OneToMany(mappedBy = "dictionary", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
+ private List<DictionaryElement> dictionaryElements = new ArrayList<>();
+
+ /**
+ * name getter.
+ *
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * name setter.
+ *
+ * @param name the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * secondLevelDictionary getter.
+ *
+ * @return the secondLevelDictionary
+ */
+ public int getSecondLevelDictionary() {
+ return secondLevelDictionary;
+ }
+
+ /**
+ * secondLevelDictionary setter.
+ *
+ * @param secondLevelDictionary the secondLevelDictionary to set
+ */
+ public void setSecondLevelDictionary(int secondLevelDictionary) {
+ this.secondLevelDictionary = secondLevelDictionary;
+ }
+
+ /**
+ * subDictionaryType getter.
+ *
+ * @return the subDictionaryType
+ */
+ public String getSubDictionaryType() {
+ return subDictionaryType;
+ }
+
+ /**
+ * subDictionaryType setter.
+ *
+ * @param subDictionaryType the subDictionaryType to set
+ */
+ public void setSubDictionaryType(String subDictionaryType) {
+ this.subDictionaryType = subDictionaryType;
+ }
+
+ /**
+ * dictionaryElements getter.
+ *
+ * @return the dictionaryElements
+ */
+ public List<DictionaryElement> getDictionaryElements() {
+ return dictionaryElements;
+ }
+
+ /**
+ * dictionaryElements setter.
+ *
+ * @param dictionaryElements the dictionaryElements to set
+ */
+ public void setDictionaryElements(List<DictionaryElement> dictionaryElements) {
+ this.dictionaryElements = dictionaryElements;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ Dictionary other = (Dictionary) obj;
+ if (name == null) {
+ if (other.name != null) {
+ return false;
+ }
+ } else if (!name.equals(other.name)) {
+ return false;
+ }
+ return true;
+ }
+
+}
diff --git a/src/main/java/org/onap/clamp/tosca/DictionaryElement.java b/src/main/java/org/onap/clamp/tosca/DictionaryElement.java
new file mode 100644
index 000000000..e81885f3e
--- /dev/null
+++ b/src/main/java/org/onap/clamp/tosca/DictionaryElement.java
@@ -0,0 +1,249 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.tosca;
+
+import com.google.gson.annotations.Expose;
+
+import java.io.Serializable;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+
+import org.onap.clamp.loop.common.AuditEntity;
+
+/**
+ * Represents a Dictionary Item.
+ */
+@Entity
+@Table(name = "dictionary_elements")
+public class DictionaryElement extends AuditEntity implements Serializable {
+
+ /**
+ * The serial version id.
+ */
+ private static final long serialVersionUID = -286522707701388644L;
+
+ @Id
+ @Expose
+ @Column(nullable = false, name = "name", unique = true)
+ private String name;
+
+ @Expose
+ @Column(nullable = false, name = "short_name", unique = true)
+ private String shortName;
+
+ @Expose
+ @Column(name = "description")
+ private String description;
+
+ @Expose
+ @Column(nullable = false, name = "type")
+ private String type;
+
+ @Column(name = "subdictionary_id", nullable = false)
+ @Expose
+ private String subDictionary;
+
+ @ManyToOne(cascade = CascadeType.ALL)
+ @JoinColumn(name = "dictionary_id")
+ private Dictionary dictionary;
+
+ /**
+ * name getter.
+ *
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * name setter.
+ *
+ * @param name the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * shortName getter.
+ *
+ * @return the shortName
+ */
+ public String getShortName() {
+ return shortName;
+ }
+
+ /**
+ * shortName setter.
+ *
+ * @param shortName the shortName to set
+ */
+ public void setShortName(String shortName) {
+ this.shortName = shortName;
+ }
+
+ /**
+ * description getter.
+ *
+ * @return the description
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * description setter.
+ *
+ * @param description the description to set
+ */
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ /**
+ * type getter.
+ *
+ * @return the type
+ */
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * type setter.
+ *
+ * @param type the type to set
+ */
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ /**
+ * subDictionary getter.
+ *
+ * @return the subDictionary
+ */
+ public String getSubDictionary() {
+ return subDictionary;
+ }
+
+ /**
+ * subDictionary setter.
+ *
+ * @param subDictionary the subDictionary to set
+ */
+ public void setSubDictionary(String subDictionary) {
+ this.subDictionary = subDictionary;
+ }
+
+ /**
+ * dictionary getter.
+ *
+ * @return the dictionary
+ */
+ public Dictionary getDictionary() {
+ return dictionary;
+ }
+
+ /**
+ * dictionary setter.
+ *
+ * @param dictionary the dictionary to set
+ */
+ public void setDictionary(Dictionary dictionary) {
+ this.dictionary = dictionary;
+ }
+
+ /**
+ * Default Constructor.
+ */
+ public DictionaryElement() {
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param name The Dictionary element name
+ * @param shortName The short name
+ * @param description The description
+ * @param type The type of element
+ * @param subDictionary The sub type
+ * @param dictionary The parent dictionary
+ */
+ public DictionaryElement(String name, String shortName, String description, String type, String subDictionary,
+ Dictionary dictionary) {
+ this.name = name;
+ this.shortName = shortName;
+ this.description = description;
+ this.type = type;
+ this.subDictionary = subDictionary;
+ this.dictionary = dictionary;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((dictionary == null) ? 0 : dictionary.hashCode());
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ DictionaryElement other = (DictionaryElement) obj;
+ if (dictionary == null) {
+ if (other.dictionary != null) {
+ return false;
+ }
+ } else if (!dictionary.equals(other.dictionary)) {
+ return false;
+ }
+ if (name == null) {
+ if (other.name != null) {
+ return false;
+ }
+ } else if (!name.equals(other.name)) {
+ return false;
+ }
+ return true;
+ }
+
+}
diff --git a/src/main/java/org/onap/clamp/tosca/DictionaryElementsRepository.java b/src/main/java/org/onap/clamp/tosca/DictionaryElementsRepository.java
new file mode 100644
index 000000000..96cb2e35e
--- /dev/null
+++ b/src/main/java/org/onap/clamp/tosca/DictionaryElementsRepository.java
@@ -0,0 +1,32 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.tosca;
+
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface DictionaryElementsRepository extends JpaRepository<DictionaryElement, String> {
+
+}
diff --git a/src/main/java/org/onap/clamp/tosca/DictionaryRepository.java b/src/main/java/org/onap/clamp/tosca/DictionaryRepository.java
new file mode 100644
index 000000000..2a087b6d9
--- /dev/null
+++ b/src/main/java/org/onap/clamp/tosca/DictionaryRepository.java
@@ -0,0 +1,38 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.tosca;
+
+import java.util.List;
+
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface DictionaryRepository extends JpaRepository<Dictionary, String> {
+
+ @Query("SELECT dict.name FROM Dictionary as dict")
+ List<String> getAllDictionaryNames();
+
+}
diff --git a/src/main/java/org/onap/clamp/util/SemanticVersioning.java b/src/main/java/org/onap/clamp/util/SemanticVersioning.java
new file mode 100644
index 000000000..bf1529c2c
--- /dev/null
+++ b/src/main/java/org/onap/clamp/util/SemanticVersioning.java
@@ -0,0 +1,76 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2020 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.util;
+
+/**
+ * This class is the base class for object that requires semantic versioning.
+ * ... This class supports also a.b.c.d... etc ... as a version.
+ *
+ *
+ */
+public class SemanticVersioning {
+ public static final int BEFORE = -1;
+ public static final int EQUAL = 0;
+ public static final int AFTER = 1;
+
+ /**
+ * The compare method that compare arg0 to arg1.
+ *
+ * @param arg0 A version in string for semantice versioning (a.b.c.d...)
+ * @param arg1 A version in string for semantice versioning (a.b.c.d...)
+ * @return objects (arg0, arg1) given as parameters. It returns the value: 0: if
+ * (arg0==arg1) -1: if (arg0 < arg1) 1: if (arg0 > arg1)
+ */
+ public static int compare(String arg0, String arg1) {
+
+ if (arg0 == null && arg1 == null) {
+ return EQUAL;
+ }
+ if (arg0 == null) {
+ return BEFORE;
+ }
+ if (arg1 == null) {
+ return AFTER;
+ }
+ String[] arg0Array = arg0.split("\\.");
+ String[] arg1Array = arg1.split("\\.");
+
+ int smalestStringLength = Math.min(arg0Array.length, arg1Array.length);
+
+ for (int currentVersionIndex = 0; currentVersionIndex < smalestStringLength; ++currentVersionIndex) {
+ if (Integer.parseInt(arg0Array[currentVersionIndex]) < Integer.parseInt(arg1Array[currentVersionIndex])) {
+ return BEFORE;
+ } else if (Integer.parseInt(arg0Array[currentVersionIndex]) > Integer
+ .parseInt(arg1Array[currentVersionIndex])) {
+ return AFTER;
+ }
+ // equals, so do not return anything, continue
+ }
+ if (arg0Array.length == arg1Array.length) {
+ return EQUAL;
+ } else {
+ return Integer.compare(arg0Array.length, arg1Array.length);
+ }
+ }
+} \ No newline at end of file
diff --git a/src/main/resources/META-INF/resources/swagger.html b/src/main/resources/META-INF/resources/swagger.html
index b20d0c26c..66024470a 100644
--- a/src/main/resources/META-INF/resources/swagger.html
+++ b/src/main/resources/META-INF/resources/swagger.html
@@ -444,86 +444,86 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
</li>
<li><a href="#_paths">2. Paths</a>
<ul class="sectlevel2">
-<li><a href="#_route15">2.1. GET /v1/clds/cldsInfo</a>
+<li><a href="#_route32">2.1. GET /v1/clds/cldsInfo</a>
<ul class="sectlevel3">
<li><a href="#_responses">2.1.1. Responses</a></li>
<li><a href="#_produces">2.1.2. Produces</a></li>
</ul>
</li>
-<li><a href="#_route16">2.2. GET /v1/healthcheck</a>
+<li><a href="#_route33">2.2. GET /v1/healthcheck</a>
<ul class="sectlevel3">
<li><a href="#_responses_2">2.2.1. Responses</a></li>
<li><a href="#_produces_2">2.2.2. Produces</a></li>
</ul>
</li>
-<li><a href="#_route17">2.3. GET /v1/user/getUser</a>
+<li><a href="#_route34">2.3. GET /v1/user/getUser</a>
<ul class="sectlevel3">
<li><a href="#_responses_3">2.3.1. Responses</a></li>
<li><a href="#_produces_3">2.3.2. Produces</a></li>
</ul>
</li>
-<li><a href="#_route13">2.4. PUT /v2/loop/delete/{loopName}</a>
+<li><a href="#_route30">2.4. PUT /v2/loop/delete/{loopName}</a>
<ul class="sectlevel3">
<li><a href="#_parameters">2.4.1. Parameters</a></li>
<li><a href="#_responses_4">2.4.2. Responses</a></li>
</ul>
</li>
-<li><a href="#_route8">2.5. PUT /v2/loop/deploy/{loopName}</a>
+<li><a href="#_route25">2.5. PUT /v2/loop/deploy/{loopName}</a>
<ul class="sectlevel3">
<li><a href="#_parameters_2">2.5.1. Parameters</a></li>
<li><a href="#_responses_5">2.5.2. Responses</a></li>
<li><a href="#_produces_4">2.5.3. Produces</a></li>
</ul>
</li>
-<li><a href="#_route2">2.6. GET /v2/loop/getAllNames</a>
+<li><a href="#_route19">2.6. GET /v2/loop/getAllNames</a>
<ul class="sectlevel3">
<li><a href="#_responses_6">2.6.1. Responses</a></li>
<li><a href="#_produces_5">2.6.2. Produces</a></li>
</ul>
</li>
-<li><a href="#_route14">2.7. GET /v2/loop/getstatus/{loopName}</a>
+<li><a href="#_route31">2.7. GET /v2/loop/getstatus/{loopName}</a>
<ul class="sectlevel3">
<li><a href="#_parameters_3">2.7.1. Parameters</a></li>
<li><a href="#_responses_7">2.7.2. Responses</a></li>
<li><a href="#_produces_6">2.7.3. Produces</a></li>
</ul>
</li>
-<li><a href="#_route11">2.8. PUT /v2/loop/restart/{loopName}</a>
+<li><a href="#_route28">2.8. PUT /v2/loop/restart/{loopName}</a>
<ul class="sectlevel3">
<li><a href="#_parameters_4">2.8.1. Parameters</a></li>
<li><a href="#_responses_8">2.8.2. Responses</a></li>
<li><a href="#_produces_7">2.8.3. Produces</a></li>
</ul>
</li>
-<li><a href="#_route10">2.9. PUT /v2/loop/stop/{loopName}</a>
+<li><a href="#_route27">2.9. PUT /v2/loop/stop/{loopName}</a>
<ul class="sectlevel3">
<li><a href="#_parameters_5">2.9.1. Parameters</a></li>
<li><a href="#_responses_9">2.9.2. Responses</a></li>
<li><a href="#_produces_8">2.9.3. Produces</a></li>
</ul>
</li>
-<li><a href="#_route12">2.10. PUT /v2/loop/submit/{loopName}</a>
+<li><a href="#_route29">2.10. PUT /v2/loop/submit/{loopName}</a>
<ul class="sectlevel3">
<li><a href="#_parameters_6">2.10.1. Parameters</a></li>
<li><a href="#_responses_10">2.10.2. Responses</a></li>
<li><a href="#_produces_9">2.10.3. Produces</a></li>
</ul>
</li>
-<li><a href="#_route4">2.11. GET /v2/loop/svgRepresentation/{loopName}</a>
+<li><a href="#_route21">2.11. GET /v2/loop/svgRepresentation/{loopName}</a>
<ul class="sectlevel3">
<li><a href="#_parameters_7">2.11.1. Parameters</a></li>
<li><a href="#_responses_11">2.11.2. Responses</a></li>
<li><a href="#_produces_10">2.11.3. Produces</a></li>
</ul>
</li>
-<li><a href="#_route9">2.12. PUT /v2/loop/undeploy/{loopName}</a>
+<li><a href="#_route26">2.12. PUT /v2/loop/undeploy/{loopName}</a>
<ul class="sectlevel3">
<li><a href="#_parameters_8">2.12.1. Parameters</a></li>
<li><a href="#_responses_12">2.12.2. Responses</a></li>
<li><a href="#_produces_11">2.12.3. Produces</a></li>
</ul>
</li>
-<li><a href="#_route5">2.13. POST /v2/loop/updateGlobalProperties/{loopName}</a>
+<li><a href="#_route22">2.13. POST /v2/loop/updateGlobalProperties/{loopName}</a>
<ul class="sectlevel3">
<li><a href="#_parameters_9">2.13.1. Parameters</a></li>
<li><a href="#_responses_13">2.13.2. Responses</a></li>
@@ -531,7 +531,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
<li><a href="#_produces_12">2.13.4. Produces</a></li>
</ul>
</li>
-<li><a href="#_route7">2.14. POST /v2/loop/updateMicroservicePolicy/{loopName}</a>
+<li><a href="#_route24">2.14. POST /v2/loop/updateMicroservicePolicy/{loopName}</a>
<ul class="sectlevel3">
<li><a href="#_parameters_10">2.14.1. Parameters</a></li>
<li><a href="#_responses_14">2.14.2. Responses</a></li>
@@ -539,7 +539,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
<li><a href="#_produces_13">2.14.4. Produces</a></li>
</ul>
</li>
-<li><a href="#_route6">2.15. POST /v2/loop/updateOperationalPolicies/{loopName}</a>
+<li><a href="#_route23">2.15. POST /v2/loop/updateOperationalPolicies/{loopName}</a>
<ul class="sectlevel3">
<li><a href="#_parameters_11">2.15.1. Parameters</a></li>
<li><a href="#_responses_15">2.15.2. Responses</a></li>
@@ -547,7 +547,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
<li><a href="#_produces_14">2.15.4. Produces</a></li>
</ul>
</li>
-<li><a href="#_route3">2.16. GET /v2/loop/{loopName}</a>
+<li><a href="#_route20">2.16. GET /v2/loop/{loopName}</a>
<ul class="sectlevel3">
<li><a href="#_parameters_12">2.16.1. Parameters</a></li>
<li><a href="#_responses_16">2.16.2. Responses</a></li>
@@ -568,9 +568,14 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
<li><a href="#_jsonprimitive">3.8. JsonPrimitive</a></li>
<li><a href="#_loop">3.9. Loop</a></li>
<li><a href="#_looplog">3.10. LoopLog</a></li>
-<li><a href="#_microservicepolicy">3.11. MicroServicePolicy</a></li>
-<li><a href="#_number">3.12. Number</a></li>
-<li><a href="#_operationalpolicy">3.13. OperationalPolicy</a></li>
+<li><a href="#_looptemplate">3.11. LoopTemplate</a></li>
+<li><a href="#_microservicemodel">3.12. MicroServiceModel</a></li>
+<li><a href="#_microservicepolicy">3.13. MicroServicePolicy</a></li>
+<li><a href="#_number">3.14. Number</a></li>
+<li><a href="#_operationalpolicy">3.15. OperationalPolicy</a></li>
+<li><a href="#_policymodel">3.16. PolicyModel</a></li>
+<li><a href="#_service">3.17. Service</a></li>
+<li><a href="#_templatemicroservicemodel">3.18. TemplateMicroServiceModel</a></li>
</ul>
</li>
</ul>
@@ -583,13 +588,13 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
<div class="sect2">
<h3 id="_version_information"><a class="anchor" href="#_version_information"></a><a class="link" href="#_version_information">1.1. Version information</a></h3>
<div class="paragraph">
-<p><em>Version</em> : 4.1.2-SNAPSHOT</p>
+<p><em>Version</em> : 4.2.0-SNAPSHOT</p>
</div>
</div>
<div class="sect2">
<h3 id="_uri_scheme"><a class="anchor" href="#_uri_scheme"></a><a class="link" href="#_uri_scheme">1.2. URI scheme</a></h3>
<div class="paragraph">
-<p><em>Host</em> : localhost:34219<br>
+<p><em>Host</em> : localhost:33953<br>
<em>BasePath</em> : /restservices/clds/<br>
<em>Schemes</em> : HTTP</p>
</div>
@@ -600,7 +605,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
<h2 id="_paths"><a class="anchor" href="#_paths"></a><a class="link" href="#_paths">2. Paths</a></h2>
<div class="sectionbody">
<div class="sect2">
-<h3 id="_route15"><a class="anchor" href="#_route15"></a><a class="link" href="#_route15">2.1. GET /v1/clds/cldsInfo</a></h3>
+<h3 id="_route32"><a class="anchor" href="#_route32"></a><a class="link" href="#_route32">2.1. GET /v1/clds/cldsInfo</a></h3>
<div class="sect3">
<h4 id="_responses"><a class="anchor" href="#_responses"></a><a class="link" href="#_responses">2.1.1. Responses</a></h4>
<table class="tableblock frame-all grid-all stretch">
@@ -637,7 +642,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
</div>
</div>
<div class="sect2">
-<h3 id="_route16"><a class="anchor" href="#_route16"></a><a class="link" href="#_route16">2.2. GET /v1/healthcheck</a></h3>
+<h3 id="_route33"><a class="anchor" href="#_route33"></a><a class="link" href="#_route33">2.2. GET /v1/healthcheck</a></h3>
<div class="sect3">
<h4 id="_responses_2"><a class="anchor" href="#_responses_2"></a><a class="link" href="#_responses_2">2.2.1. Responses</a></h4>
<table class="tableblock frame-all grid-all stretch">
@@ -674,7 +679,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
</div>
</div>
<div class="sect2">
-<h3 id="_route17"><a class="anchor" href="#_route17"></a><a class="link" href="#_route17">2.3. GET /v1/user/getUser</a></h3>
+<h3 id="_route34"><a class="anchor" href="#_route34"></a><a class="link" href="#_route34">2.3. GET /v1/user/getUser</a></h3>
<div class="sect3">
<h4 id="_responses_3"><a class="anchor" href="#_responses_3"></a><a class="link" href="#_responses_3">2.3.1. Responses</a></h4>
<table class="tableblock frame-all grid-all stretch">
@@ -708,7 +713,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
</div>
</div>
<div class="sect2">
-<h3 id="_route13"><a class="anchor" href="#_route13"></a><a class="link" href="#_route13">2.4. PUT /v2/loop/delete/{loopName}</a></h3>
+<h3 id="_route30"><a class="anchor" href="#_route30"></a><a class="link" href="#_route30">2.4. PUT /v2/loop/delete/{loopName}</a></h3>
<div class="sect3">
<h4 id="_parameters"><a class="anchor" href="#_parameters"></a><a class="link" href="#_parameters">2.4.1. Parameters</a></h4>
<table class="tableblock frame-all grid-all stretch">
@@ -757,7 +762,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
</div>
</div>
<div class="sect2">
-<h3 id="_route8"><a class="anchor" href="#_route8"></a><a class="link" href="#_route8">2.5. PUT /v2/loop/deploy/{loopName}</a></h3>
+<h3 id="_route25"><a class="anchor" href="#_route25"></a><a class="link" href="#_route25">2.5. PUT /v2/loop/deploy/{loopName}</a></h3>
<div class="sect3">
<h4 id="_parameters_2"><a class="anchor" href="#_parameters_2"></a><a class="link" href="#_parameters_2">2.5.1. Parameters</a></h4>
<table class="tableblock frame-all grid-all stretch">
@@ -819,7 +824,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
</div>
</div>
<div class="sect2">
-<h3 id="_route2"><a class="anchor" href="#_route2"></a><a class="link" href="#_route2">2.6. GET /v2/loop/getAllNames</a></h3>
+<h3 id="_route19"><a class="anchor" href="#_route19"></a><a class="link" href="#_route19">2.6. GET /v2/loop/getAllNames</a></h3>
<div class="sect3">
<h4 id="_responses_6"><a class="anchor" href="#_responses_6"></a><a class="link" href="#_responses_6">2.6.1. Responses</a></h4>
<table class="tableblock frame-all grid-all stretch">
@@ -856,7 +861,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
</div>
</div>
<div class="sect2">
-<h3 id="_route14"><a class="anchor" href="#_route14"></a><a class="link" href="#_route14">2.7. GET /v2/loop/getstatus/{loopName}</a></h3>
+<h3 id="_route31"><a class="anchor" href="#_route31"></a><a class="link" href="#_route31">2.7. GET /v2/loop/getstatus/{loopName}</a></h3>
<div class="sect3">
<h4 id="_parameters_3"><a class="anchor" href="#_parameters_3"></a><a class="link" href="#_parameters_3">2.7.1. Parameters</a></h4>
<table class="tableblock frame-all grid-all stretch">
@@ -918,7 +923,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
</div>
</div>
<div class="sect2">
-<h3 id="_route11"><a class="anchor" href="#_route11"></a><a class="link" href="#_route11">2.8. PUT /v2/loop/restart/{loopName}</a></h3>
+<h3 id="_route28"><a class="anchor" href="#_route28"></a><a class="link" href="#_route28">2.8. PUT /v2/loop/restart/{loopName}</a></h3>
<div class="sect3">
<h4 id="_parameters_4"><a class="anchor" href="#_parameters_4"></a><a class="link" href="#_parameters_4">2.8.1. Parameters</a></h4>
<table class="tableblock frame-all grid-all stretch">
@@ -980,7 +985,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
</div>
</div>
<div class="sect2">
-<h3 id="_route10"><a class="anchor" href="#_route10"></a><a class="link" href="#_route10">2.9. PUT /v2/loop/stop/{loopName}</a></h3>
+<h3 id="_route27"><a class="anchor" href="#_route27"></a><a class="link" href="#_route27">2.9. PUT /v2/loop/stop/{loopName}</a></h3>
<div class="sect3">
<h4 id="_parameters_5"><a class="anchor" href="#_parameters_5"></a><a class="link" href="#_parameters_5">2.9.1. Parameters</a></h4>
<table class="tableblock frame-all grid-all stretch">
@@ -1042,7 +1047,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
</div>
</div>
<div class="sect2">
-<h3 id="_route12"><a class="anchor" href="#_route12"></a><a class="link" href="#_route12">2.10. PUT /v2/loop/submit/{loopName}</a></h3>
+<h3 id="_route29"><a class="anchor" href="#_route29"></a><a class="link" href="#_route29">2.10. PUT /v2/loop/submit/{loopName}</a></h3>
<div class="sect3">
<h4 id="_parameters_6"><a class="anchor" href="#_parameters_6"></a><a class="link" href="#_parameters_6">2.10.1. Parameters</a></h4>
<table class="tableblock frame-all grid-all stretch">
@@ -1104,7 +1109,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
</div>
</div>
<div class="sect2">
-<h3 id="_route4"><a class="anchor" href="#_route4"></a><a class="link" href="#_route4">2.11. GET /v2/loop/svgRepresentation/{loopName}</a></h3>
+<h3 id="_route21"><a class="anchor" href="#_route21"></a><a class="link" href="#_route21">2.11. GET /v2/loop/svgRepresentation/{loopName}</a></h3>
<div class="sect3">
<h4 id="_parameters_7"><a class="anchor" href="#_parameters_7"></a><a class="link" href="#_parameters_7">2.11.1. Parameters</a></h4>
<table class="tableblock frame-all grid-all stretch">
@@ -1166,7 +1171,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
</div>
</div>
<div class="sect2">
-<h3 id="_route9"><a class="anchor" href="#_route9"></a><a class="link" href="#_route9">2.12. PUT /v2/loop/undeploy/{loopName}</a></h3>
+<h3 id="_route26"><a class="anchor" href="#_route26"></a><a class="link" href="#_route26">2.12. PUT /v2/loop/undeploy/{loopName}</a></h3>
<div class="sect3">
<h4 id="_parameters_8"><a class="anchor" href="#_parameters_8"></a><a class="link" href="#_parameters_8">2.12.1. Parameters</a></h4>
<table class="tableblock frame-all grid-all stretch">
@@ -1228,7 +1233,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
</div>
</div>
<div class="sect2">
-<h3 id="_route5"><a class="anchor" href="#_route5"></a><a class="link" href="#_route5">2.13. POST /v2/loop/updateGlobalProperties/{loopName}</a></h3>
+<h3 id="_route22"><a class="anchor" href="#_route22"></a><a class="link" href="#_route22">2.13. POST /v2/loop/updateGlobalProperties/{loopName}</a></h3>
<div class="sect3">
<h4 id="_parameters_9"><a class="anchor" href="#_parameters_9"></a><a class="link" href="#_parameters_9">2.13.1. Parameters</a></h4>
<table class="tableblock frame-all grid-all stretch">
@@ -1306,7 +1311,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
</div>
</div>
<div class="sect2">
-<h3 id="_route7"><a class="anchor" href="#_route7"></a><a class="link" href="#_route7">2.14. POST /v2/loop/updateMicroservicePolicy/{loopName}</a></h3>
+<h3 id="_route24"><a class="anchor" href="#_route24"></a><a class="link" href="#_route24">2.14. POST /v2/loop/updateMicroservicePolicy/{loopName}</a></h3>
<div class="sect3">
<h4 id="_parameters_10"><a class="anchor" href="#_parameters_10"></a><a class="link" href="#_parameters_10">2.14.1. Parameters</a></h4>
<table class="tableblock frame-all grid-all stretch">
@@ -1384,7 +1389,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
</div>
</div>
<div class="sect2">
-<h3 id="_route6"><a class="anchor" href="#_route6"></a><a class="link" href="#_route6">2.15. POST /v2/loop/updateOperationalPolicies/{loopName}</a></h3>
+<h3 id="_route23"><a class="anchor" href="#_route23"></a><a class="link" href="#_route23">2.15. POST /v2/loop/updateOperationalPolicies/{loopName}</a></h3>
<div class="sect3">
<h4 id="_parameters_11"><a class="anchor" href="#_parameters_11"></a><a class="link" href="#_parameters_11">2.15.1. Parameters</a></h4>
<table class="tableblock frame-all grid-all stretch">
@@ -1462,7 +1467,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
</div>
</div>
<div class="sect2">
-<h3 id="_route3"><a class="anchor" href="#_route3"></a><a class="link" href="#_route3">2.16. GET /v2/loop/{loopName}</a></h3>
+<h3 id="_route20"><a class="anchor" href="#_route20"></a><a class="link" href="#_route20">2.16. GET /v2/loop/{loopName}</a></h3>
<div class="sect3">
<h4 id="_parameters_12"><a class="anchor" href="#_parameters_12"></a><a class="link" href="#_parameters_12">2.16.1. Parameters</a></h4>
<table class="tableblock frame-all grid-all stretch">
@@ -2184,6 +2189,16 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
<td class="tableblock halign-left valign-middle"><p class="tableblock">&lt; string, <a href="#_externalcomponent">ExternalComponent</a> &gt; map</p></td>
</tr>
<tr>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>createdBy</strong><br>
+<em>optional</em></p></td>
+<td class="tableblock halign-left valign-middle"><p class="tableblock">string</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>createdDate</strong><br>
+<em>optional</em></p></td>
+<td class="tableblock halign-left valign-middle"><p class="tableblock">integer (int64)</p></td>
+</tr>
+<tr>
<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>dcaeBlueprintId</strong><br>
<em>optional</em></p></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock">string</p></td>
@@ -2214,14 +2229,19 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
<td class="tableblock halign-left valign-middle"><p class="tableblock">&lt; <a href="#_looplog">LoopLog</a> &gt; array</p></td>
</tr>
<tr>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>loopTemplate</strong><br>
+<em>optional</em></p></td>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><a href="#_looptemplate">LoopTemplate</a></p></td>
+</tr>
+<tr>
<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>microServicePolicies</strong><br>
<em>optional</em></p></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock">&lt; <a href="#_microservicepolicy">MicroServicePolicy</a> &gt; array</p></td>
</tr>
<tr>
-<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>modelPropertiesJson</strong><br>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>modelService</strong><br>
<em>optional</em></p></td>
-<td class="tableblock halign-left valign-middle"><p class="tableblock"><a href="#_jsonobject">JsonObject</a></p></td>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><a href="#_service">Service</a></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>name</strong><br>
@@ -2238,6 +2258,16 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
<em>optional</em></p></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock">string</p></td>
</tr>
+<tr>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>updatedBy</strong><br>
+<em>optional</em></p></td>
+<td class="tableblock halign-left valign-middle"><p class="tableblock">string</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>updatedDate</strong><br>
+<em>optional</em></p></td>
+<td class="tableblock halign-left valign-middle"><p class="tableblock">integer (int64)</p></td>
+</tr>
</tbody>
</table>
</div>
@@ -2289,7 +2319,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
</table>
</div>
<div class="sect2">
-<h3 id="_microservicepolicy"><a class="anchor" href="#_microservicepolicy"></a><a class="link" href="#_microservicepolicy">3.11. MicroServicePolicy</a></h3>
+<h3 id="_looptemplate"><a class="anchor" href="#_looptemplate"></a><a class="link" href="#_looptemplate">3.11. LoopTemplate</a></h3>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 42.8571%;">
@@ -2303,11 +2333,165 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
</thead>
<tbody>
<tr>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>blueprint</strong><br>
+<em>optional</em></p></td>
+<td class="tableblock halign-left valign-middle"><p class="tableblock">string</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>createdBy</strong><br>
+<em>optional</em></p></td>
+<td class="tableblock halign-left valign-middle"><p class="tableblock">string</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>createdDate</strong><br>
+<em>optional</em></p></td>
+<td class="tableblock halign-left valign-middle"><p class="tableblock">integer (int64)</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>maximumInstancesAllowed</strong><br>
+<em>optional</em></p></td>
+<td class="tableblock halign-left valign-middle"><p class="tableblock">integer (int32)</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>microServiceModelUsed</strong><br>
+<em>optional</em></p></td>
+<td class="tableblock halign-left valign-middle"><p class="tableblock">&lt; <a href="#_templatemicroservicemodel">TemplateMicroServiceModel</a> &gt; array</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>modelService</strong><br>
+<em>optional</em></p></td>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><a href="#_service">Service</a></p></td>
+</tr>
+<tr>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>name</strong><br>
+<em>optional</em></p></td>
+<td class="tableblock halign-left valign-middle"><p class="tableblock">string</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>svgRepresentation</strong><br>
+<em>optional</em></p></td>
+<td class="tableblock halign-left valign-middle"><p class="tableblock">string</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>updatedBy</strong><br>
+<em>optional</em></p></td>
+<td class="tableblock halign-left valign-middle"><p class="tableblock">string</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>updatedDate</strong><br>
+<em>optional</em></p></td>
+<td class="tableblock halign-left valign-middle"><p class="tableblock">integer (int64)</p></td>
+</tr>
+</tbody>
+</table>
+</div>
+<div class="sect2">
+<h3 id="_microservicemodel"><a class="anchor" href="#_microservicemodel"></a><a class="link" href="#_microservicemodel">3.12. MicroServiceModel</a></h3>
+<table class="tableblock frame-all grid-all stretch">
+<colgroup>
+<col style="width: 42.8571%;">
+<col style="width: 57.1429%;">
+</colgroup>
+<thead>
+<tr>
+<th class="tableblock halign-left valign-middle">Name</th>
+<th class="tableblock halign-left valign-middle">Schema</th>
+</tr>
+</thead>
+<tbody>
+<tr>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>blueprint</strong><br>
+<em>optional</em></p></td>
+<td class="tableblock halign-left valign-middle"><p class="tableblock">string</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>createdBy</strong><br>
+<em>optional</em></p></td>
+<td class="tableblock halign-left valign-middle"><p class="tableblock">string</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>createdDate</strong><br>
+<em>optional</em></p></td>
+<td class="tableblock halign-left valign-middle"><p class="tableblock">integer (int64)</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>name</strong><br>
+<em>optional</em></p></td>
+<td class="tableblock halign-left valign-middle"><p class="tableblock">string</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>policyModel</strong><br>
+<em>optional</em></p></td>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><a href="#_policymodel">PolicyModel</a></p></td>
+</tr>
+<tr>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>policyType</strong><br>
+<em>optional</em></p></td>
+<td class="tableblock halign-left valign-middle"><p class="tableblock">string</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>updatedBy</strong><br>
+<em>optional</em></p></td>
+<td class="tableblock halign-left valign-middle"><p class="tableblock">string</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>updatedDate</strong><br>
+<em>optional</em></p></td>
+<td class="tableblock halign-left valign-middle"><p class="tableblock">integer (int64)</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>usedByLoopTemplates</strong><br>
+<em>optional</em></p></td>
+<td class="tableblock halign-left valign-middle"><p class="tableblock">&lt; <a href="#_templatemicroservicemodel">TemplateMicroServiceModel</a> &gt; array</p></td>
+</tr>
+</tbody>
+</table>
+</div>
+<div class="sect2">
+<h3 id="_microservicepolicy"><a class="anchor" href="#_microservicepolicy"></a><a class="link" href="#_microservicepolicy">3.13. MicroServicePolicy</a></h3>
+<table class="tableblock frame-all grid-all stretch">
+<colgroup>
+<col style="width: 42.8571%;">
+<col style="width: 57.1429%;">
+</colgroup>
+<thead>
+<tr>
+<th class="tableblock halign-left valign-middle">Name</th>
+<th class="tableblock halign-left valign-middle">Schema</th>
+</tr>
+</thead>
+<tbody>
+<tr>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>context</strong><br>
+<em>optional</em></p></td>
+<td class="tableblock halign-left valign-middle"><p class="tableblock">string</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>createdBy</strong><br>
+<em>optional</em></p></td>
+<td class="tableblock halign-left valign-middle"><p class="tableblock">string</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>createdDate</strong><br>
+<em>optional</em></p></td>
+<td class="tableblock halign-left valign-middle"><p class="tableblock">integer (int64)</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>deviceTypeScope</strong><br>
+<em>optional</em></p></td>
+<td class="tableblock halign-left valign-middle"><p class="tableblock">string</p></td>
+</tr>
+<tr>
<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>jsonRepresentation</strong><br>
<em>optional</em></p></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock"><a href="#_jsonobject">JsonObject</a></p></td>
</tr>
<tr>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>microServiceModel</strong><br>
+<em>optional</em></p></td>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><a href="#_microservicemodel">MicroServiceModel</a></p></td>
+</tr>
+<tr>
<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>modelType</strong><br>
<em>optional</em></p></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock">string</p></td>
@@ -2333,6 +2517,16 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
<td class="tableblock halign-left valign-middle"><p class="tableblock">boolean</p></td>
</tr>
<tr>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>updatedBy</strong><br>
+<em>optional</em></p></td>
+<td class="tableblock halign-left valign-middle"><p class="tableblock">string</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>updatedDate</strong><br>
+<em>optional</em></p></td>
+<td class="tableblock halign-left valign-middle"><p class="tableblock">integer (int64)</p></td>
+</tr>
+<tr>
<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>usedByLoops</strong><br>
<em>optional</em></p></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock">&lt; <a href="#_loop">Loop</a> &gt; array</p></td>
@@ -2341,13 +2535,13 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
</table>
</div>
<div class="sect2">
-<h3 id="_number"><a class="anchor" href="#_number"></a><a class="link" href="#_number">3.12. Number</a></h3>
+<h3 id="_number"><a class="anchor" href="#_number"></a><a class="link" href="#_number">3.14. Number</a></h3>
<div class="paragraph">
<p><em>Type</em> : object</p>
</div>
</div>
<div class="sect2">
-<h3 id="_operationalpolicy"><a class="anchor" href="#_operationalpolicy"></a><a class="link" href="#_operationalpolicy">3.13. OperationalPolicy</a></h3>
+<h3 id="_operationalpolicy"><a class="anchor" href="#_operationalpolicy"></a><a class="link" href="#_operationalpolicy">3.15. OperationalPolicy</a></h3>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 42.8571%;">
@@ -2380,6 +2574,137 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
<em>optional</em></p></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock">string</p></td>
</tr>
+<tr>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>policyModel</strong><br>
+<em>optional</em></p></td>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><a href="#_policymodel">PolicyModel</a></p></td>
+</tr>
+</tbody>
+</table>
+</div>
+<div class="sect2">
+<h3 id="_policymodel"><a class="anchor" href="#_policymodel"></a><a class="link" href="#_policymodel">3.16. PolicyModel</a></h3>
+<table class="tableblock frame-all grid-all stretch">
+<colgroup>
+<col style="width: 42.8571%;">
+<col style="width: 57.1429%;">
+</colgroup>
+<thead>
+<tr>
+<th class="tableblock halign-left valign-middle">Name</th>
+<th class="tableblock halign-left valign-middle">Schema</th>
+</tr>
+</thead>
+<tbody>
+<tr>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>createdBy</strong><br>
+<em>optional</em></p></td>
+<td class="tableblock halign-left valign-middle"><p class="tableblock">string</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>createdDate</strong><br>
+<em>optional</em></p></td>
+<td class="tableblock halign-left valign-middle"><p class="tableblock">integer (int64)</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>policyAcronym</strong><br>
+<em>optional</em></p></td>
+<td class="tableblock halign-left valign-middle"><p class="tableblock">string</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>policyModelTosca</strong><br>
+<em>optional</em></p></td>
+<td class="tableblock halign-left valign-middle"><p class="tableblock">string</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>policyModelType</strong><br>
+<em>optional</em></p></td>
+<td class="tableblock halign-left valign-middle"><p class="tableblock">string</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>policyVariant</strong><br>
+<em>optional</em></p></td>
+<td class="tableblock halign-left valign-middle"><p class="tableblock">string</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>updatedBy</strong><br>
+<em>optional</em></p></td>
+<td class="tableblock halign-left valign-middle"><p class="tableblock">string</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>updatedDate</strong><br>
+<em>optional</em></p></td>
+<td class="tableblock halign-left valign-middle"><p class="tableblock">integer (int64)</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>version</strong><br>
+<em>optional</em></p></td>
+<td class="tableblock halign-left valign-middle"><p class="tableblock">string</p></td>
+</tr>
+</tbody>
+</table>
+</div>
+<div class="sect2">
+<h3 id="_service"><a class="anchor" href="#_service"></a><a class="link" href="#_service">3.17. Service</a></h3>
+<table class="tableblock frame-all grid-all stretch">
+<colgroup>
+<col style="width: 42.8571%;">
+<col style="width: 57.1429%;">
+</colgroup>
+<thead>
+<tr>
+<th class="tableblock halign-left valign-middle">Name</th>
+<th class="tableblock halign-left valign-middle">Schema</th>
+</tr>
+</thead>
+<tbody>
+<tr>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>resourceDetails</strong><br>
+<em>optional</em></p></td>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><a href="#_jsonobject">JsonObject</a></p></td>
+</tr>
+<tr>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>serviceDetails</strong><br>
+<em>optional</em></p></td>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><a href="#_jsonobject">JsonObject</a></p></td>
+</tr>
+<tr>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>serviceUuid</strong><br>
+<em>optional</em></p></td>
+<td class="tableblock halign-left valign-middle"><p class="tableblock">string</p></td>
+</tr>
+</tbody>
+</table>
+</div>
+<div class="sect2">
+<h3 id="_templatemicroservicemodel"><a class="anchor" href="#_templatemicroservicemodel"></a><a class="link" href="#_templatemicroservicemodel">3.18. TemplateMicroServiceModel</a></h3>
+<table class="tableblock frame-all grid-all stretch">
+<colgroup>
+<col style="width: 42.8571%;">
+<col style="width: 57.1429%;">
+</colgroup>
+<thead>
+<tr>
+<th class="tableblock halign-left valign-middle">Name</th>
+<th class="tableblock halign-left valign-middle">Schema</th>
+</tr>
+</thead>
+<tbody>
+<tr>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>flowOrder</strong><br>
+<em>optional</em></p></td>
+<td class="tableblock halign-left valign-middle"><p class="tableblock">integer (int32)</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>loopTemplate</strong><br>
+<em>optional</em></p></td>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><a href="#_looptemplate">LoopTemplate</a></p></td>
+</tr>
+<tr>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>microServiceModel</strong><br>
+<em>optional</em></p></td>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><a href="#_microservicemodel">MicroServiceModel</a></p></td>
+</tr>
</tbody>
</table>
</div>
@@ -2388,7 +2713,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
</div>
<div id="footer">
<div id="footer-text">
-Last updated 2019-05-27 14:30:20 CEST
+Last updated 2019-10-29 10:41:43 CET
</div>
</div>
</body>
diff --git a/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java b/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java
index df952aa16..2ebea7b17 100644
--- a/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java
+++ b/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java
@@ -63,7 +63,7 @@ import org.skyscreamer.jsonassert.JSONAssert;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.annotation.Rollback;
+import org.springframework.test.annotation.Commit;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
@@ -183,7 +183,7 @@ public class CsarInstallerItCase {
@Test
@Transactional
- @Rollback(value = false)
+ @Commit
public void testInstallTheCsarTca() throws SdcArtifactInstallerException, SdcToscaParserException,
CsarHandlerException, IOException, JSONException, InterruptedException {
String generatedName = RandomStringUtils.randomAlphanumeric(5);
@@ -209,7 +209,7 @@ public class CsarInstallerItCase {
assertThat(loop.getOperationalPolicies()).hasSize(1);
assertThat(loop.getModelService().getServiceUuid()).isEqualTo("63cac700-ab9a-4115-a74f-7eac85e3fce0");
JSONAssert.assertEquals(ResourceFileUtil.getResourceAsString("tosca/model-properties.json"),
- JsonUtils.GSON_JPA_MODEL.toJson(loop.getModelService()), true);
+ JsonUtils.GSON_JPA_MODEL.toJson(loop.getModelService()), true);
JSONAssert.assertEquals(ResourceFileUtil.getResourceAsString("tosca/service-details.json"),
JsonUtils.GSON_JPA_MODEL.toJson(loop.getModelService().getServiceDetails()), true);
JSONAssert.assertEquals(ResourceFileUtil.getResourceAsString("tosca/resource-details.json"),
diff --git a/src/test/java/org/onap/clamp/loop/LoopControllerTestItCase.java b/src/test/java/org/onap/clamp/loop/LoopControllerTestItCase.java
index 67ae985c7..a41b5c251 100644
--- a/src/test/java/org/onap/clamp/loop/LoopControllerTestItCase.java
+++ b/src/test/java/org/onap/clamp/loop/LoopControllerTestItCase.java
@@ -32,18 +32,15 @@ import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import java.util.Set;
+
import javax.transaction.Transactional;
-import org.junit.After;
-import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-
import org.onap.clamp.clds.Application;
import org.onap.clamp.clds.util.JsonUtils;
-
import org.onap.clamp.policy.microservice.MicroServicePolicy;
-import org.onap.clamp.policy.microservice.MicroservicePolicyService;
+import org.onap.clamp.policy.microservice.MicroServicePolicyService;
import org.onap.clamp.policy.operational.OperationalPolicy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
@@ -63,7 +60,7 @@ public class LoopControllerTestItCase {
LoopsRepository loopsRepository;
@Autowired
- MicroservicePolicyService microServicePolicyService;
+ MicroServicePolicyService microServicePolicyService;
@Autowired
LoopController loopController;
@@ -78,18 +75,10 @@ public class LoopControllerTestItCase {
return new Loop(loopName, loopBlueprint, loopSvg);
}
- @Before
- public void setUp() {
- saveTestLoopToDb();
- }
-
- @After
- public void tearDown() {
- loopsRepository.deleteAll();
- }
-
@Test
+ @Transactional
public void testUpdateOperationalPolicies() {
+ saveTestLoopToDb();
String policy = "[{\"name\":\"OPERATIONAL_CLholmes31_v1_0_vFW_PG_T10_k8s-holmes-rules\","
+ "\"configurationsJson\":{\"guard_policies\":{},"
+ "\"operational_policy\":{\"controlLoop\":{\"trigger_policy\":\"unique-policy-id-1-modifyConfig\","
@@ -113,6 +102,7 @@ public class LoopControllerTestItCase {
@Test
@Transactional
public void testUpdateGlobalProperties() {
+ saveTestLoopToDb();
String policy = "{\"dcaeDeployParameters\":{\"aaiEnrichmentHost\":\"aai.onap.svc.cluster.local\","
+ "\"aaiEnrichmentPort\":\"8443\",\"enableAAIEnrichment\":\"false\",\"dmaap_host\":\"message-router"
+ ".onap\",\"dmaap_port\":\"3904\",\"enableRedisCaching\":\"false\",\"redisHosts\":\"dcae-redis.onap"
@@ -134,9 +124,10 @@ public class LoopControllerTestItCase {
@Test
@Transactional
public void testUpdateMicroservicePolicy() {
+ saveTestLoopToDb();
MicroServicePolicy policy = new MicroServicePolicy("policyName", "",
- "tosca_definitions_version: tosca_simple_yaml_1_0_0", false,
- JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null);
+ "tosca_definitions_version: tosca_simple_yaml_1_0_0", false,
+ JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null);
loopController.updateMicroservicePolicy(EXAMPLE_LOOP_NAME, policy);
assertThat(microServicePolicyService.isExisting("policyName")).isTrue();
}
@@ -144,7 +135,8 @@ public class LoopControllerTestItCase {
@Test
@Transactional
public void testGetSvgRepresentation() {
- String svgRepresentation = loopController.getSvgRepresentation(EXAMPLE_LOOP_NAME);
+ saveTestLoopToDb();
+ String svgRepresentation = loopController.getSvgRepresentation(EXAMPLE_LOOP_NAME);
assertThat(svgRepresentation).isEqualTo("representation");
}
} \ No newline at end of file
diff --git a/src/test/java/org/onap/clamp/loop/LoopLogServiceTestItCase.java b/src/test/java/org/onap/clamp/loop/LoopLogServiceTestItCase.java
index 57b2cef61..c172a9a07 100644
--- a/src/test/java/org/onap/clamp/loop/LoopLogServiceTestItCase.java
+++ b/src/test/java/org/onap/clamp/loop/LoopLogServiceTestItCase.java
@@ -27,11 +27,11 @@ import static org.assertj.core.api.Assertions.assertThat;
import com.google.gson.JsonObject;
import java.util.Set;
+
import javax.transaction.Transactional;
import org.junit.Test;
import org.junit.runner.RunWith;
-
import org.onap.clamp.clds.Application;
import org.onap.clamp.clds.util.JsonUtils;
import org.onap.clamp.loop.log.LogType;
@@ -77,10 +77,10 @@ public class LoopLogServiceTestItCase {
assertThat(loopLogs).hasSize(1);
LoopLog loopLog = loopLogs.iterator().next();
assertThat(loopLog.getMessage()).isEqualTo(SAMPLE_LOG_MESSAGE);
- loopsRepository.deleteAll();
}
@Test
+ @Transactional
public void testLoopLog() {
LoopLog log = new LoopLog();
Long id = Long.valueOf(100);
diff --git a/src/test/java/org/onap/clamp/loop/LoopRepositoriesItCase.java b/src/test/java/org/onap/clamp/loop/LoopRepositoriesItCase.java
index 78e0d2e3d..44feaebd8 100644
--- a/src/test/java/org/onap/clamp/loop/LoopRepositoriesItCase.java
+++ b/src/test/java/org/onap/clamp/loop/LoopRepositoriesItCase.java
@@ -40,8 +40,17 @@ import org.onap.clamp.clds.Application;
import org.onap.clamp.loop.log.LogType;
import org.onap.clamp.loop.log.LoopLog;
import org.onap.clamp.loop.log.LoopLogRepository;
+import org.onap.clamp.loop.service.Service;
+import org.onap.clamp.loop.service.ServicesRepository;
+import org.onap.clamp.loop.template.LoopTemplate;
+import org.onap.clamp.loop.template.LoopTemplatesRepository;
+import org.onap.clamp.loop.template.MicroServiceModel;
+import org.onap.clamp.loop.template.MicroServiceModelsRepository;
+import org.onap.clamp.loop.template.PolicyModel;
+import org.onap.clamp.loop.template.PolicyModelId;
+import org.onap.clamp.loop.template.PolicyModelsRepository;
import org.onap.clamp.policy.microservice.MicroServicePolicy;
-import org.onap.clamp.policy.microservice.MicroservicePolicyService;
+import org.onap.clamp.policy.microservice.MicroServicePolicyService;
import org.onap.clamp.policy.operational.OperationalPolicy;
import org.onap.clamp.policy.operational.OperationalPolicyService;
import org.springframework.beans.factory.annotation.Autowired;
@@ -59,7 +68,7 @@ public class LoopRepositoriesItCase {
private LoopsRepository loopRepository;
@Autowired
- private MicroservicePolicyService microServicePolicyService;
+ private MicroServicePolicyService microServicePolicyService;
@Autowired
private OperationalPolicyService operationalPolicyService;
@@ -67,12 +76,47 @@ public class LoopRepositoriesItCase {
@Autowired
private LoopLogRepository loopLogRepository;
+ @Autowired
+ private LoopTemplatesRepository loopTemplateRepository;
+
+ @Autowired
+ private MicroServiceModelsRepository microServiceModelsRepository;
+
+ @Autowired
+ private PolicyModelsRepository policyModelsRepository;
+
+ @Autowired
+ private ServicesRepository servicesRepository;
+
+ private Service getService(String serviceDetails, String resourceDetails) {
+ return new Service(serviceDetails, resourceDetails);
+ }
+
private OperationalPolicy getOperationalPolicy(String configJson, String name) {
return new OperationalPolicy(name, null, new Gson().fromJson(configJson, JsonObject.class));
}
+ private MicroServiceModel getMicroServiceModel(String yaml, String name, String policyType, String createdBy,
+ PolicyModel policyModel) {
+ MicroServiceModel model = new MicroServiceModel(name, policyType, yaml, policyModel);
+ return model;
+ }
+
+ private PolicyModel getPolicyModel(String policyType, String policyModelTosca, String version, String policyAcronym,
+ String policyVariant, String createdBy) {
+ return new PolicyModel(policyType, policyModelTosca, version, policyAcronym, policyVariant);
+ }
+
+ private LoopTemplate getLoopTemplate(String name, String blueprint, String svgRepresentation, String createdBy,
+ Integer maxInstancesAllowed) {
+ LoopTemplate template = new LoopTemplate(name, blueprint, svgRepresentation, maxInstancesAllowed, null);
+ template.addMicroServiceModel(getMicroServiceModel("yaml", "microService1", "org.onap.policy.drools", createdBy,
+ getPolicyModel("org.onap.policy.drools", "yaml", "1.0.0", "Drools", "type1", createdBy)));
+ return template;
+ }
+
private Loop getLoop(String name, String svgRepresentation, String blueprint, String globalPropertiesJson,
- String dcaeId, String dcaeUrl, String dcaeBlueprintId) {
+ String dcaeId, String dcaeUrl, String dcaeBlueprintId) {
Loop loop = new Loop();
loop.setName(name);
loop.setSvgRepresentation(svgRepresentation);
@@ -82,13 +126,14 @@ public class LoopRepositoriesItCase {
loop.setDcaeDeploymentId(dcaeId);
loop.setDcaeDeploymentStatusUrl(dcaeUrl);
loop.setDcaeBlueprintId(dcaeBlueprintId);
+ loop.setLoopTemplate(getLoopTemplate("templateName", "yaml", "svg", "toto", 1));
return loop;
}
private MicroServicePolicy getMicroServicePolicy(String name, String modelType, String jsonRepresentation,
- String policyTosca, String jsonProperties, boolean shared) {
+ String policyTosca, String jsonProperties, boolean shared) {
MicroServicePolicy microService = new MicroServicePolicy(name, modelType, policyTosca, shared,
- gson.fromJson(jsonRepresentation, JsonObject.class), new HashSet<>());
+ gson.fromJson(jsonRepresentation, JsonObject.class), new HashSet<>());
microService.setProperties(new Gson().fromJson(jsonProperties, JsonObject.class));
return microService;
}
@@ -100,52 +145,108 @@ public class LoopRepositoriesItCase {
@Test
@Transactional
public void crudTest() {
+ // Setup
Loop loopTest = getLoop("ControlLoopTest", "<xml></xml>", "yamlcontent", "{\"testname\":\"testvalue\"}",
- "123456789", "https://dcaetest.org", "UUID-blueprint");
+ "123456789", "https://dcaetest.org", "UUID-blueprint");
OperationalPolicy opPolicy = this.getOperationalPolicy("{\"type\":\"GUARD\"}", "GuardOpPolicyTest");
loopTest.addOperationalPolicy(opPolicy);
MicroServicePolicy microServicePolicy = getMicroServicePolicy("configPolicyTest", "",
- "{\"configtype\":\"json\"}", "tosca_definitions_version: tosca_simple_yaml_1_0_0",
- "{\"param1\":\"value1\"}", true);
+ "{\"configtype\":\"json\"}", "tosca_definitions_version: tosca_simple_yaml_1_0_0",
+ "{\"param1\":\"value1\"}", true);
loopTest.addMicroServicePolicy(microServicePolicy);
LoopLog loopLog = getLoopLog(LogType.INFO, "test message", loopTest);
loopTest.addLog(loopLog);
+ Service service = getService(
+ "{\"name\": \"vLoadBalancerMS\", \"UUID\": \"63cac700-ab9a-4115-a74f-7eac85e3fce0\"}", "{\"CP\": {}}");
+ loopTest.setModelService(service);
- // Attemp to save into the database the entire loop
+ // Attempt to save into the database the entire loop
Loop loopInDb = loopRepository.save(loopTest);
assertThat(loopInDb).isNotNull();
+ assertThat(loopRepository.findById(loopInDb.getName()).get()).isNotNull();
+ assertThat(loopInDb.getCreatedDate()).isNotNull();
+ assertThat(loopInDb.getUpdatedDate()).isNotNull();
+ assertThat(loopInDb.getUpdatedDate()).isEqualTo(loopInDb.getCreatedDate());
assertThat(loopInDb.getName()).isEqualTo("ControlLoopTest");
- // Now set the ID in the previous model so that we can compare the objects
+ // Autogen id so now set the ID in the previous model so that we can compare the
+ // objects
loopLog.setId(((LoopLog) loopInDb.getLoopLogs().toArray()[0]).getId());
- assertThat(loopInDb).isEqualToIgnoringGivenFields(loopTest, "components");
+ assertThat(loopInDb).isEqualToIgnoringGivenFields(loopTest, "components", "createdDate", "updatedDate",
+ "createdBy", "updatedBy");
assertThat(loopRepository.existsById(loopTest.getName())).isEqualTo(true);
assertThat(operationalPolicyService.isExisting(opPolicy.getName())).isEqualTo(true);
assertThat(microServicePolicyService.isExisting(microServicePolicy.getName())).isEqualTo(true);
assertThat(loopLogRepository.existsById(loopLog.getId())).isEqualTo(true);
+ assertThat(loopTemplateRepository.existsById(loopInDb.getLoopTemplate().getName())).isEqualTo(true);
+ assertThat(loopTemplateRepository.existsById(loopInDb.getLoopTemplate().getName())).isEqualTo(true);
+ assertThat(servicesRepository.existsById(loopInDb.getModelService().getServiceUuid())).isEqualTo(true);
+ assertThat(microServiceModelsRepository.existsById(
+ loopInDb.getLoopTemplate().getMicroServiceModelUsed().first().getMicroServiceModel().getName()))
+ .isEqualTo(true);
+ assertThat(policyModelsRepository.existsById(new PolicyModelId(
+ loopInDb.getLoopTemplate().getMicroServiceModelUsed().first().getMicroServiceModel().getPolicyModel()
+ .getPolicyModelType(),
+ loopInDb.getLoopTemplate().getMicroServiceModelUsed().first().getMicroServiceModel().getPolicyModel()
+ .getVersion()))).isEqualTo(true);
// Now attempt to read from database
Loop loopInDbRetrieved = loopRepository.findById(loopTest.getName()).get();
- assertThat(loopInDbRetrieved).isEqualToIgnoringGivenFields(loopTest, "components");
+ assertThat(loopInDbRetrieved).isEqualToIgnoringGivenFields(loopTest, "components", "createdDate", "updatedDate",
+ "createdBy", "updatedBy");
+ assertThat(loopInDbRetrieved).isEqualToComparingOnlyGivenFields(loopInDb, "createdDate", "updatedDate",
+ "createdBy", "updatedBy");
assertThat((LoopLog) loopInDbRetrieved.getLoopLogs().toArray()[0]).isEqualToComparingFieldByField(loopLog);
assertThat((OperationalPolicy) loopInDbRetrieved.getOperationalPolicies().toArray()[0])
- .isEqualToComparingFieldByField(opPolicy);
+ .isEqualToComparingFieldByField(opPolicy);
assertThat((MicroServicePolicy) loopInDbRetrieved.getMicroServicePolicies().toArray()[0])
- .isEqualToComparingFieldByField(microServicePolicy);
+ .isEqualToIgnoringGivenFields(microServicePolicy, "createdDate", "updatedDate", "createdBy",
+ "updatedBy");
// Attempt an update
((LoopLog) loopInDbRetrieved.getLoopLogs().toArray()[0]).setLogInstant(Instant.now());
- loopRepository.save(loopInDbRetrieved);
- Loop loopInDbRetrievedUpdated = loopRepository.findById(loopTest.getName()).get();
+ loopInDbRetrieved.setBlueprint("yaml2");
+ Loop loopInDbRetrievedUpdated = loopRepository.saveAndFlush(loopInDbRetrieved);
+ // Loop loopInDbRetrievedUpdated =
+ // loopRepository.findById(loopTest.getName()).get();
+ assertThat(loopInDbRetrievedUpdated.getBlueprint()).isEqualTo("yaml2");
assertThat((LoopLog) loopInDbRetrievedUpdated.getLoopLogs().toArray()[0])
- .isEqualToComparingFieldByField(loopInDbRetrieved.getLoopLogs().toArray()[0]);
+ .isEqualToComparingFieldByField(loopInDbRetrieved.getLoopLogs().toArray()[0]);
+ // UpdatedDate should have been changed
+ assertThat(loopInDbRetrievedUpdated.getUpdatedDate()).isNotEqualTo(loopInDbRetrievedUpdated.getCreatedDate());
+ // createdDate should have NOT been changed
+ assertThat(loopInDbRetrievedUpdated.getCreatedDate()).isEqualTo(loopInDb.getCreatedDate());
+ // other audit are the same
+ assertThat(loopInDbRetrievedUpdated.getCreatedBy()).isEqualTo("");
+ assertThat(loopInDbRetrievedUpdated.getUpdatedBy()).isEqualTo("");
// Attempt to delete the object and check it has well been cascaded
+
loopRepository.delete(loopInDbRetrieved);
assertThat(loopRepository.existsById(loopTest.getName())).isEqualTo(false);
assertThat(operationalPolicyService.isExisting(opPolicy.getName())).isEqualTo(false);
- assertThat(microServicePolicyService.isExisting(microServicePolicy.getName())).isEqualTo(false);
+ assertThat(microServicePolicyService.isExisting(microServicePolicy.getName())).isEqualTo(true);
assertThat(loopLogRepository.existsById(loopLog.getId())).isEqualTo(false);
+ assertThat(loopTemplateRepository.existsById(loopInDb.getLoopTemplate().getName())).isEqualTo(true);
+ assertThat(servicesRepository.existsById(loopInDb.getModelService().getServiceUuid())).isEqualTo(true);
+ assertThat(microServiceModelsRepository.existsById(
+ loopInDb.getLoopTemplate().getMicroServiceModelUsed().first().getMicroServiceModel().getName()))
+ .isEqualTo(true);
+
+ assertThat(policyModelsRepository.existsById(new PolicyModelId(
+ loopInDb.getLoopTemplate().getMicroServiceModelUsed().first().getMicroServiceModel().getPolicyModel()
+ .getPolicyModelType(),
+ loopInDb.getLoopTemplate().getMicroServiceModelUsed().first().getMicroServiceModel().getPolicyModel()
+ .getVersion()))).isEqualTo(true);
+
+ // Cleanup
+ // microServiceModelsRepository
+ // .delete(loopInDb.getLoopTemplate().getMicroServiceModelUsed().first().getMicroServiceModel());
+ //
+ // policyModelsRepository.delete(
+ // loopInDb.getLoopTemplate().getMicroServiceModelUsed().first().getMicroServiceModel().getPolicyModel());
+ // loopTemplateRepository.delete(loopInDb.getLoopTemplate());
+ // servicesRepository.delete(service);
}
}
diff --git a/src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java b/src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java
index 28a92e371..d19c8a808 100644
--- a/src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java
+++ b/src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java
@@ -33,7 +33,6 @@ import java.util.stream.Collectors;
import javax.transaction.Transactional;
import org.assertj.core.util.Lists;
-import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.clamp.clds.Application;
@@ -42,7 +41,7 @@ import org.onap.clamp.loop.log.LogType;
import org.onap.clamp.loop.log.LoopLog;
import org.onap.clamp.loop.log.LoopLogService;
import org.onap.clamp.policy.microservice.MicroServicePolicy;
-import org.onap.clamp.policy.microservice.MicroservicePolicyService;
+import org.onap.clamp.policy.microservice.MicroServicePolicyService;
import org.onap.clamp.policy.operational.OperationalPolicy;
import org.onap.clamp.policy.operational.OperationalPolicyService;
import org.springframework.beans.factory.annotation.Autowired;
@@ -63,7 +62,7 @@ public class LoopServiceTestItCase {
LoopsRepository loopsRepository;
@Autowired
- MicroservicePolicyService microServicePolicyService;
+ MicroServicePolicyService microServicePolicyService;
@Autowired
OperationalPolicyService operationalPolicyService;
@@ -71,11 +70,6 @@ public class LoopServiceTestItCase {
@Autowired
LoopLogService loopLogService;
- @After
- public void tearDown() {
- loopsRepository.deleteAll();
- }
-
@Test
@Transactional
public void shouldCreateEmptyLoop() {
@@ -96,7 +90,7 @@ public class LoopServiceTestItCase {
assertThat(actualLoop.getBlueprint()).isEqualTo(loopBlueprint);
assertThat(actualLoop.getSvgRepresentation()).isEqualTo(loopSvg);
assertThat(actualLoop.getGlobalPropertiesJson().getAsJsonPrimitive("testName").getAsString())
- .isEqualTo("testValue");
+ .isEqualTo("testValue");
}
@Test
@@ -105,11 +99,11 @@ public class LoopServiceTestItCase {
// given
saveTestLoopToDb();
OperationalPolicy operationalPolicy = new OperationalPolicy("policyName", null,
- JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class));
+ JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class));
// when
Loop actualLoop = loopService.updateAndSaveOperationalPolicies(EXAMPLE_LOOP_NAME,
- Lists.newArrayList(operationalPolicy));
+ Lists.newArrayList(operationalPolicy));
// then
assertThat(actualLoop).isNotNull();
@@ -128,20 +122,20 @@ public class LoopServiceTestItCase {
// given
saveTestLoopToDb();
MicroServicePolicy microServicePolicy = new MicroServicePolicy("policyName", "",
- "tosca_definitions_version: tosca_simple_yaml_1_0_0", false,
- JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null);
+ "tosca_definitions_version: tosca_simple_yaml_1_0_0", false,
+ JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null);
// when
Loop actualLoop = loopService.updateAndSaveMicroservicePolicies(EXAMPLE_LOOP_NAME,
- Lists.newArrayList(microServicePolicy));
+ Lists.newArrayList(microServicePolicy));
// then
assertThat(actualLoop).isNotNull();
assertThat(actualLoop.getName()).isEqualTo(EXAMPLE_LOOP_NAME);
Set<MicroServicePolicy> savedPolicies = actualLoop.getMicroServicePolicies();
assertThat(savedPolicies).hasSize(1);
- assertThat(savedPolicies).usingElementComparatorIgnoringFields("usedByLoops")
- .containsExactly(microServicePolicy);
+ assertThat(savedPolicies).usingElementComparatorIgnoringFields("usedByLoops", "createdDate", "updatedDate",
+ "createdBy", "updatedBy").containsExactly(microServicePolicy);
assertThat(savedPolicies).extracting("usedByLoops").hasSize(1);
}
@@ -153,16 +147,16 @@ public class LoopServiceTestItCase {
saveTestLoopToDb();
MicroServicePolicy firstMicroServicePolicy = new MicroServicePolicy("firstPolicyName", "", "", false,
- JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null);
+ JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null);
loopService.updateAndSaveMicroservicePolicies(EXAMPLE_LOOP_NAME, Lists.newArrayList(firstMicroServicePolicy));
MicroServicePolicy secondMicroServicePolicy = new MicroServicePolicy("secondPolicyName", "",
- "tosca_definitions_version: tosca_simple_yaml_1_0_0", true, JsonUtils.GSON.fromJson("{}", JsonObject.class),
- null);
+ "tosca_definitions_version: tosca_simple_yaml_1_0_0", true,
+ JsonUtils.GSON.fromJson("{}", JsonObject.class), null);
// when
firstMicroServicePolicy.setProperties(JsonUtils.GSON.fromJson("{\"name1\":\"value1\"}", JsonObject.class));
Loop actualLoop = loopService.updateAndSaveMicroservicePolicies(EXAMPLE_LOOP_NAME,
- Lists.newArrayList(firstMicroServicePolicy, secondMicroServicePolicy));
+ Lists.newArrayList(firstMicroServicePolicy, secondMicroServicePolicy));
// then
assertThat(actualLoop).isNotNull();
@@ -171,8 +165,8 @@ public class LoopServiceTestItCase {
assertThat(savedPolicies).hasSize(2);
assertThat(savedPolicies).contains(firstMicroServicePolicy);
assertThat(savedPolicies).contains(secondMicroServicePolicy);
- assertThat(savedPolicies).usingElementComparatorIgnoringFields("usedByLoops")
- .containsExactlyInAnyOrder(firstMicroServicePolicy, secondMicroServicePolicy);
+ assertThat(savedPolicies).usingElementComparatorIgnoringFields("usedByLoops", "createdDate", "updatedDate",
+ "createdBy", "updatedBy").containsExactlyInAnyOrder(firstMicroServicePolicy, secondMicroServicePolicy);
}
@@ -189,24 +183,24 @@ public class LoopServiceTestItCase {
saveTestLoopToDb();
MicroServicePolicy firstMicroServicePolicy = new MicroServicePolicy("firstPolicyName", "",
- "\"tosca_definitions_version: tosca_simple_yaml_1_0_0\"", false,
- JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null);
+ "\"tosca_definitions_version: tosca_simple_yaml_1_0_0\"", false,
+ JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null);
loopService.updateAndSaveMicroservicePolicies(EXAMPLE_LOOP_NAME, Lists.newArrayList(firstMicroServicePolicy));
MicroServicePolicy secondMicroServicePolicy = new MicroServicePolicy("policyName", "", "secondPolicyTosca",
- true, JsonUtils.GSON.fromJson("{}", JsonObject.class), null);
+ true, JsonUtils.GSON.fromJson("{}", JsonObject.class), null);
// when
Loop actualLoop = loopService.updateAndSaveMicroservicePolicies(EXAMPLE_LOOP_NAME,
- Lists.newArrayList(secondMicroServicePolicy));
+ Lists.newArrayList(secondMicroServicePolicy));
// then
assertThat(actualLoop).isNotNull();
assertThat(actualLoop.getName()).isEqualTo(EXAMPLE_LOOP_NAME);
Set<MicroServicePolicy> savedPolicies = actualLoop.getMicroServicePolicies();
assertThat(savedPolicies).hasSize(1);
- assertThat(savedPolicies).usingElementComparatorIgnoringFields("usedByLoops")
- .containsExactly(secondMicroServicePolicy);
+ assertThat(savedPolicies).usingElementComparatorIgnoringFields("usedByLoops", "createdDate", "updatedDate",
+ "createdBy", "updatedBy").containsExactly(secondMicroServicePolicy);
}
@@ -219,16 +213,16 @@ public class LoopServiceTestItCase {
JsonObject newJsonConfiguration = JsonUtils.GSON.fromJson("{}", JsonObject.class);
OperationalPolicy firstOperationalPolicy = new OperationalPolicy("firstPolicyName", null,
- JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class));
+ JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class));
loopService.updateAndSaveOperationalPolicies(EXAMPLE_LOOP_NAME, Lists.newArrayList(firstOperationalPolicy));
OperationalPolicy secondOperationalPolicy = new OperationalPolicy("secondPolicyName", null,
- newJsonConfiguration);
+ newJsonConfiguration);
// when
firstOperationalPolicy.setConfigurationsJson(newJsonConfiguration);
Loop actualLoop = loopService.updateAndSaveOperationalPolicies(EXAMPLE_LOOP_NAME,
- Lists.newArrayList(firstOperationalPolicy, secondOperationalPolicy));
+ Lists.newArrayList(firstOperationalPolicy, secondOperationalPolicy));
// then
assertThat(actualLoop).isNotNull();
@@ -236,9 +230,9 @@ public class LoopServiceTestItCase {
Set<OperationalPolicy> savedPolicies = actualLoop.getOperationalPolicies();
assertThat(savedPolicies).hasSize(2);
assertThat(savedPolicies).usingElementComparatorIgnoringFields("loop")
- .containsExactlyInAnyOrder(firstOperationalPolicy, secondOperationalPolicy);
+ .containsExactlyInAnyOrder(firstOperationalPolicy, secondOperationalPolicy);
Set<String> policiesLoops = Lists.newArrayList(savedPolicies).stream().map(OperationalPolicy::getLoop)
- .map(Loop::getName).collect(Collectors.toSet());
+ .map(Loop::getName).collect(Collectors.toSet());
assertThat(policiesLoops).containsExactly(EXAMPLE_LOOP_NAME);
}
@@ -249,15 +243,15 @@ public class LoopServiceTestItCase {
saveTestLoopToDb();
OperationalPolicy firstOperationalPolicy = new OperationalPolicy("firstPolicyName", null,
- JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class));
+ JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class));
loopService.updateAndSaveOperationalPolicies(EXAMPLE_LOOP_NAME, Lists.newArrayList(firstOperationalPolicy));
OperationalPolicy secondOperationalPolicy = new OperationalPolicy("policyName", null,
- JsonUtils.GSON.fromJson("{}", JsonObject.class));
+ JsonUtils.GSON.fromJson("{}", JsonObject.class));
// when
Loop actualLoop = loopService.updateAndSaveOperationalPolicies(EXAMPLE_LOOP_NAME,
- Lists.newArrayList(secondOperationalPolicy));
+ Lists.newArrayList(secondOperationalPolicy));
// then
assertThat(actualLoop).isNotNull();
@@ -300,21 +294,21 @@ public class LoopServiceTestItCase {
loop = loopService.saveOrUpdateLoop(loop);
// Add op policy
OperationalPolicy operationalPolicy = new OperationalPolicy("opPolicy", null,
- JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class));
+ JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class));
loopService.updateAndSaveOperationalPolicies(EXAMPLE_LOOP_NAME, Lists.newArrayList(operationalPolicy));
// Add Micro service policy
MicroServicePolicy microServicePolicy = new MicroServicePolicy("microPolicy", "",
- "tosca_definitions_version: tosca_simple_yaml_1_0_0", false,
- JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null);
+ "tosca_definitions_version: tosca_simple_yaml_1_0_0", false,
+ JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null);
loopService.updateAndSaveMicroservicePolicies(EXAMPLE_LOOP_NAME, Lists.newArrayList(microServicePolicy));
// Verify it's there
assertThat(loopsRepository.findById(EXAMPLE_LOOP_NAME).orElse(null)).isNotNull();
loopService.deleteLoop(EXAMPLE_LOOP_NAME);
- // Verify it's well deleted and has been cascaded
+ // Verify it's well deleted and has been cascaded, except for Microservice
assertThat(loopsRepository.findById(EXAMPLE_LOOP_NAME).orElse(null)).isNull();
- assertThat(microServicePolicyService.isExisting("microPolicy")).isFalse();
+ assertThat(microServicePolicyService.isExisting("microPolicy")).isTrue();
assertThat(operationalPolicyService.isExisting("opPolicy")).isFalse();
assertThat(loopLogService.isExisting(((LoopLog) loop.getLoopLogs().toArray()[0]).getId())).isFalse();
}
@@ -334,8 +328,8 @@ public class LoopServiceTestItCase {
public void testUpdateDcaeDeploymentFields() {
saveTestLoopToDb();
Loop loop = loopService.getLoop(EXAMPLE_LOOP_NAME);
- loopService.updateDcaeDeploymentFields(loop,"CLAMP_c5ce429a-f570-48c5-a7ea-53bed8f86f85",
- "https4://deployment-handler.onap:8443");
+ loopService.updateDcaeDeploymentFields(loop, "CLAMP_c5ce429a-f570-48c5-a7ea-53bed8f86f85",
+ "https4://deployment-handler.onap:8443");
loop = loopService.getLoop(EXAMPLE_LOOP_NAME);
assertThat(loop.getDcaeDeploymentId()).isEqualTo("CLAMP_c5ce429a-f570-48c5-a7ea-53bed8f86f85");
assertThat(loop.getDcaeDeploymentStatusUrl()).isEqualTo("https4://deployment-handler.onap:8443");
@@ -347,8 +341,8 @@ public class LoopServiceTestItCase {
saveTestLoopToDb();
assertThat(microServicePolicyService.isExisting("policyName")).isFalse();
MicroServicePolicy microServicePolicy = new MicroServicePolicy("policyName", "",
- "tosca_definitions_version: tosca_simple_yaml_1_0_0", false,
- JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null);
+ "tosca_definitions_version: tosca_simple_yaml_1_0_0", false,
+ JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null);
loopService.updateMicroservicePolicy(EXAMPLE_LOOP_NAME, microServicePolicy);
assertThat(microServicePolicyService.isExisting("policyName")).isTrue();
}
diff --git a/src/test/java/org/onap/clamp/loop/LoopToJsonTest.java b/src/test/java/org/onap/clamp/loop/LoopToJsonTest.java
index 68fe487ef..914c64ea5 100644
--- a/src/test/java/org/onap/clamp/loop/LoopToJsonTest.java
+++ b/src/test/java/org/onap/clamp/loop/LoopToJsonTest.java
@@ -44,6 +44,9 @@ import org.onap.clamp.loop.components.external.PolicyComponent;
import org.onap.clamp.loop.log.LogType;
import org.onap.clamp.loop.log.LoopLog;
import org.onap.clamp.loop.service.Service;
+import org.onap.clamp.loop.template.LoopTemplate;
+import org.onap.clamp.loop.template.MicroServiceModel;
+import org.onap.clamp.loop.template.PolicyModel;
import org.onap.clamp.policy.microservice.MicroServicePolicy;
import org.onap.clamp.policy.operational.OperationalPolicy;
import org.skyscreamer.jsonassert.JSONAssert;
@@ -72,10 +75,30 @@ public class LoopToJsonTest {
MicroServicePolicy microService = new MicroServicePolicy(name, modelType, policyTosca, shared,
gson.fromJson(jsonRepresentation, JsonObject.class), new HashSet<>());
microService.setProperties(new Gson().fromJson(jsonProperties, JsonObject.class));
-
return microService;
}
+ private MicroServiceModel getMicroServiceModel(String yaml, String name, PolicyModel policyModel) {
+ MicroServiceModel model = new MicroServiceModel();
+ model.setBlueprint(yaml);
+ model.setName(name);
+ model.setPolicyModel(policyModel);
+ return model;
+ }
+
+ private PolicyModel getPolicyModel(String policyType, String policyModelTosca, String version, String policyAcronym,
+ String policyVariant) {
+ return new PolicyModel(policyType, policyModelTosca, version, policyAcronym, policyVariant);
+ }
+
+ private LoopTemplate getLoopTemplate(String name, String blueprint, String svgRepresentation,
+ Integer maxInstancesAllowed) {
+ LoopTemplate template = new LoopTemplate(name, blueprint, svgRepresentation, maxInstancesAllowed, null);
+ template.addMicroServiceModel(getMicroServiceModel("yaml", "microService1",
+ getPolicyModel("org.onap.policy.drools", "yaml", "1.0.0", "Drools", "type1")));
+ return template;
+ }
+
private LoopLog getLoopLog(LogType type, String message, Loop loop) {
LoopLog log = new LoopLog(message, type, "CLAMP", loop);
log.setId(Long.valueOf(new Random().nextInt()));
@@ -95,6 +118,8 @@ public class LoopToJsonTest {
loopTest.addMicroServicePolicy(microServicePolicy);
LoopLog loopLog = getLoopLog(LogType.INFO, "test message", loopTest);
loopTest.addLog(loopLog);
+ LoopTemplate loopTemplate = getLoopTemplate("templateName", "yaml", "svg", 1);
+ loopTest.setLoopTemplate(loopTemplate);
String jsonSerialized = JsonUtils.GSON_JPA_MODEL.toJson(loopTest);
assertThat(jsonSerialized).isNotNull().isNotEmpty();
@@ -116,6 +141,9 @@ public class LoopToJsonTest {
assertThat(loopTestDeserialized.getLoopLogs()).containsExactly(loopLog);
assertThat((LoopLog) loopTestDeserialized.getLoopLogs().toArray()[0]).isEqualToIgnoringGivenFields(loopLog,
"loop");
+
+ // Verify the loop template
+ assertThat(loopTestDeserialized.getLoopTemplate()).isEqualTo(loopTemplate);
}
@Test
@@ -128,17 +156,14 @@ public class LoopToJsonTest {
Service service = new Service(jsonModel.get("serviceDetails").getAsJsonObject(),
jsonModel.get("resourceDetails").getAsJsonObject(), "1.0");
loopTest2.setModelService(service);
-
String jsonSerialized = JsonUtils.GSON_JPA_MODEL.toJson(loopTest2);
assertThat(jsonSerialized).isNotNull().isNotEmpty();
System.out.println(jsonSerialized);
- JSONAssert.assertEquals(ResourceFileUtil.getResourceAsString("tosca/loop.json"),
- jsonSerialized, true);
Loop loopTestDeserialized = JsonUtils.GSON_JPA_MODEL.fromJson(jsonSerialized, Loop.class);
assertNotNull(loopTestDeserialized);
- assertThat(loopTestDeserialized).isEqualToIgnoringGivenFields(loopTest2, "modelService",
- "svgRepresentation", "blueprint", "components");
+ assertThat(loopTestDeserialized).isEqualToIgnoringGivenFields(loopTest2, "modelService", "svgRepresentation",
+ "blueprint", "components");
}
@Test
diff --git a/src/test/java/org/onap/clamp/loop/PolicyModelServiceItCase.java b/src/test/java/org/onap/clamp/loop/PolicyModelServiceItCase.java
new file mode 100644
index 000000000..b284dd795
--- /dev/null
+++ b/src/test/java/org/onap/clamp/loop/PolicyModelServiceItCase.java
@@ -0,0 +1,161 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.loop;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.util.List;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+import javax.transaction.Transactional;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.clamp.clds.Application;
+import org.onap.clamp.loop.template.PolicyModel;
+import org.onap.clamp.loop.template.PolicyModelId;
+import org.onap.clamp.loop.template.PolicyModelsRepository;
+import org.onap.clamp.loop.template.PolicyModelsService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = Application.class)
+public class PolicyModelServiceItCase {
+
+ @Autowired
+ PolicyModelsService policyModelsService;
+
+ @Autowired
+ PolicyModelsRepository policyModelsRepository;
+
+ private static final String POLICY_MODEL_TYPE_1 = "org.onap.test";
+ private static final String POLICY_MODEL_TYPE_1_VERSION_1 = "1.0.0";
+
+ private static final String POLICY_MODEL_TYPE_2 = "org.onap.test2";
+ private static final String POLICY_MODEL_TYPE_2_VERSION_1 = "1.0.0";
+ private static final String POLICY_MODEL_TYPE_2_VERSION_2 = "2.0.0";
+
+ private PolicyModel getPolicyModel(String policyType, String policyModelTosca, String version, String policyAcronym,
+ String policyVariant, String createdBy) {
+ PolicyModel policyModel = new PolicyModel();
+ policyModel.setCreatedBy(createdBy);
+ policyModel.setPolicyAcronym(policyAcronym);
+ policyModel.setPolicyModelTosca(policyModelTosca);
+ policyModel.setPolicyModelType(policyType);
+ policyModel.setPolicyVariant(policyVariant);
+ policyModel.setUpdatedBy(createdBy);
+ policyModel.setVersion(version);
+ return policyModel;
+ }
+
+ @Test
+ @Transactional
+ public void shouldCreatePolicyModel() {
+ // given
+ PolicyModel policyModel = getPolicyModel(POLICY_MODEL_TYPE_1, "yaml", POLICY_MODEL_TYPE_1_VERSION_1, "TEST",
+ "VARIANT", "user");
+
+ // when
+ PolicyModel actualPolicyModel = policyModelsService.saveOrUpdatePolicyModel(policyModel);
+
+ // then
+ assertThat(actualPolicyModel).isNotNull();
+ assertThat(actualPolicyModel).isEqualTo(policyModelsRepository
+ .findById(new PolicyModelId(actualPolicyModel.getPolicyModelType(), actualPolicyModel.getVersion()))
+ .get());
+ assertThat(actualPolicyModel.getPolicyModelType()).isEqualTo(policyModel.getPolicyModelType());
+ assertThat(actualPolicyModel.getCreatedBy()).isEqualTo("");
+ assertThat(actualPolicyModel.getCreatedDate()).isNotNull();
+ assertThat(actualPolicyModel.getPolicyAcronym()).isEqualTo(policyModel.getPolicyAcronym());
+ assertThat(actualPolicyModel.getPolicyModelTosca()).isEqualTo(policyModel.getPolicyModelTosca());
+ assertThat(actualPolicyModel.getPolicyVariant()).isEqualTo(policyModel.getPolicyVariant());
+ assertThat(actualPolicyModel.getUpdatedBy()).isEqualTo("");
+ assertThat(actualPolicyModel.getUpdatedDate()).isNotNull();
+ assertThat(actualPolicyModel.getVersion()).isEqualTo(policyModel.getVersion());
+
+ assertThat(policyModelsService.getPolicyModel(POLICY_MODEL_TYPE_1, POLICY_MODEL_TYPE_1_VERSION_1))
+ .isEqualToIgnoringGivenFields(policyModel, "createdDate", "updatedDate", "createdBy", "updatedBy");
+ }
+
+ @Test
+ @Transactional
+ public void shouldReturnAllPolicyModelTypes() {
+ // given
+ PolicyModel policyModel1 = getPolicyModel(POLICY_MODEL_TYPE_2, "yaml", POLICY_MODEL_TYPE_2_VERSION_1, "TEST",
+ "VARIANT", "user");
+ policyModelsService.saveOrUpdatePolicyModel(policyModel1);
+ PolicyModel policyModel2 = getPolicyModel(POLICY_MODEL_TYPE_2, "yaml", POLICY_MODEL_TYPE_2_VERSION_2, "TEST",
+ "VARIANT", "user");
+ policyModelsService.saveOrUpdatePolicyModel(policyModel2);
+ List<String> policyModelTypesList = policyModelsService.getAllPolicyModelTypes();
+
+ assertThat(policyModelTypesList).containsOnly(policyModel1.getPolicyModelType(),
+ policyModel2.getPolicyModelType());
+ }
+
+ @Test
+ @Transactional
+ public void shouldReturnAllPolicyModels() {
+ PolicyModel policyModel1 = getPolicyModel(POLICY_MODEL_TYPE_2, "yaml", POLICY_MODEL_TYPE_2_VERSION_1, "TEST",
+ "VARIANT", "user");
+ policyModelsService.saveOrUpdatePolicyModel(policyModel1);
+ PolicyModel policyModel2 = getPolicyModel(POLICY_MODEL_TYPE_2, "yaml", POLICY_MODEL_TYPE_2_VERSION_2, "TEST",
+ "VARIANT", "user");
+ policyModelsService.saveOrUpdatePolicyModel(policyModel2);
+
+ assertThat(policyModelsService.getAllPolicyModels()).containsOnly(policyModel1, policyModel2);
+ }
+
+ @Test
+ @Transactional
+ public void shouldReturnAllModelsByType() {
+ PolicyModel policyModel1 = getPolicyModel(POLICY_MODEL_TYPE_2, "yaml", POLICY_MODEL_TYPE_2_VERSION_1, "TEST",
+ "VARIANT", "user");
+ policyModelsService.saveOrUpdatePolicyModel(policyModel1);
+ PolicyModel policyModel2 = getPolicyModel(POLICY_MODEL_TYPE_2, "yaml", POLICY_MODEL_TYPE_2_VERSION_2, "TEST",
+ "VARIANT", "user");
+ policyModelsService.saveOrUpdatePolicyModel(policyModel2);
+
+ assertThat(policyModelsService.getAllPolicyModelsByType(POLICY_MODEL_TYPE_2)).containsOnly(policyModel1,
+ policyModel2);
+ }
+
+ @Test
+ @Transactional
+ public void shouldReturnSortedSet() {
+ PolicyModel policyModel1 = getPolicyModel(POLICY_MODEL_TYPE_2, "yaml", POLICY_MODEL_TYPE_2_VERSION_1, "TEST",
+ "VARIANT", "user");
+ policyModelsService.saveOrUpdatePolicyModel(policyModel1);
+ PolicyModel policyModel2 = getPolicyModel(POLICY_MODEL_TYPE_2, "yaml", POLICY_MODEL_TYPE_2_VERSION_2, "TEST",
+ "VARIANT", "user");
+ policyModelsService.saveOrUpdatePolicyModel(policyModel2);
+
+ SortedSet<PolicyModel> sortedSet = new TreeSet<>();
+ policyModelsService.getAllPolicyModels().forEach(sortedSet::add);
+ assertThat(sortedSet).containsExactly(policyModel2, policyModel1);
+ }
+}
diff --git a/src/test/java/org/onap/clamp/util/SemanticVersioningTest.java b/src/test/java/org/onap/clamp/util/SemanticVersioningTest.java
new file mode 100644
index 000000000..1fb5922fd
--- /dev/null
+++ b/src/test/java/org/onap/clamp/util/SemanticVersioningTest.java
@@ -0,0 +1,71 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2020 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.util;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.junit.Test;
+
+public class SemanticVersioningTest {
+
+ @Test
+ public void compareTest() {
+ assertThat(SemanticVersioning.compare("1.0.0", "2.0.0")).isEqualTo(-1);
+ assertThat(SemanticVersioning.compare("1.5.0", "2.0.0")).isEqualTo(-1);
+ assertThat(SemanticVersioning.compare("1.5.0", "2.1.0")).isEqualTo(-1);
+ assertThat(SemanticVersioning.compare("1.5.3", "2.0.0")).isEqualTo(-1);
+ assertThat(SemanticVersioning.compare("2.5.3", "2.6.0")).isEqualTo(-1);
+ assertThat(SemanticVersioning.compare("2.5", "2.5.1")).isEqualTo(-1);
+ assertThat(SemanticVersioning.compare("2.5.0", "2.5.1")).isEqualTo(-1);
+ assertThat(SemanticVersioning.compare("2.5.0.0", "2.5.1")).isEqualTo(-1);
+ assertThat(SemanticVersioning.compare("2.5.1.0", "2.5.1")).isEqualTo(1);
+
+ assertThat(SemanticVersioning.compare("2.0.0", "1.0.0")).isEqualTo(1);
+ assertThat(SemanticVersioning.compare("2.0.0", "1.5.0")).isEqualTo(1);
+ assertThat(SemanticVersioning.compare("2.1.0", "1.5.0")).isEqualTo(1);
+ assertThat(SemanticVersioning.compare("2.0.0", "1.5.3")).isEqualTo(1);
+ assertThat(SemanticVersioning.compare("2.6.0", "2.5.3")).isEqualTo(1);
+ assertThat(SemanticVersioning.compare("2.5.1", "2.5")).isEqualTo(1);
+ assertThat(SemanticVersioning.compare("2.5.1", "2.5.0")).isEqualTo(1);
+ assertThat(SemanticVersioning.compare("2.5.1", "2.5.0.0")).isEqualTo(1);
+ assertThat(SemanticVersioning.compare("1", "1.2.3.0")).isEqualTo(-1);
+ assertThat(SemanticVersioning.compare("1.2", "1")).isEqualTo(1);
+ }
+
+ @Test
+ public void compareEqualsTest() {
+ assertThat(SemanticVersioning.compare("1.0.0", "1.0.0")).isEqualTo(0);
+ assertThat(SemanticVersioning.compare("1.0.0.0", "1.0.0")).isEqualTo(1);
+ assertThat(SemanticVersioning.compare("1.2.3", "1.2.3")).isEqualTo(0);
+ assertThat(SemanticVersioning.compare("1.2.3", "1.2.3.0")).isEqualTo(-1);
+
+ }
+
+ @Test
+ public void compareNullTest() {
+ assertThat(SemanticVersioning.compare(null, null)).isEqualTo(0);
+ assertThat(SemanticVersioning.compare(null, "1.0")).isEqualTo(-1);
+ assertThat(SemanticVersioning.compare("1.0", null)).isEqualTo(1);
+ }
+}