package org.onap.policy.models.base;
+import org.apache.commons.lang3.ObjectUtils;
+import org.onap.policy.common.utils.validation.Version;
+
/**
* An interface that forces a POJO to have getName() and getVersion() methods.
*
public String getVersion();
public void setVersion(final String version);
+
+ /**
+ * COmpare two name version implementation objects.
+ *
+ * @param left the left name/version implementation
+ * @param right the right name/version implementation
+ * @return the comparison resilt
+ */
+ public default int compareNameVersion(final PfNameVersion left, final PfNameVersion right) {
+ if (left == null && right == null) {
+ return 0;
+ }
+
+ if (left == null) {
+ return 1;
+ }
+
+ if (right == null) {
+ return -1;
+ }
+
+ int result = ObjectUtils.compare(left.getName(), right.getName());
+ if (result != 0) {
+ return result;
+ }
+
+ if (left.getVersion() == null && right.getVersion() == null) {
+ return 0;
+ }
+
+ if (left.getVersion() == null) {
+ return 1;
+ }
+
+ if (right.getVersion() == null) {
+ return -1;
+ }
+ return new Version(left.getVersion()).compareTo(new Version(right.getVersion()));
+ }
}
+++ /dev/null
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
- * ================================================================================
- * 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.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.models.base;
-
-import java.util.List;
-
-/**
- * Interface for filtering a list of concepts.
- *
- * @author Liam Fallon (liam.fallon@est.tech)
- */
-@FunctionalInterface
-public interface PfObjectFiler<T> {
- /**
- * Filter an incoming list, removing items that do not match the filter.
- *
- * @param originalList the original list
- * @return the filtered list
- */
- public List<T> filter(final List<T> originalList);
-
-}
--- /dev/null
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.models.base;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import lombok.NonNull;
+
+/**
+ * Interface for filtering a list of concepts.
+ *
+ * @author Liam Fallon (liam.fallon@est.tech)
+ */
+@FunctionalInterface
+public interface PfObjectFilter<T extends Comparable<T>> {
+ /**
+ * Filter an incoming list, removing items that do not match the filter.
+ *
+ * @param originalList the original list
+ * @return the filtered list
+ */
+ public List<T> filter(final List<T> originalList);
+
+ /**
+ * Check if a value matches a regular expression.
+ *
+ * @param value the incoming value to check
+ * @param regexp the regular expression to check against
+ * @return match or not
+ */
+ public default boolean filterOnRegexp(@NonNull final String value, @NonNull final String regexp) {
+ return value.matches(regexp);
+ }
+
+ /**
+ * Sort an incoming list and remove all but the latest version of each concept.
+ *
+ * @param originalList the incoming list
+ * @return the filtered list
+ */
+ public default List<T> latestVersionFilter(final List<T> originalList) {
+ List<T> filteredList = new ArrayList<>();
+ Collections.sort(filteredList);
+
+ List<T> filteredOutList = new ArrayList<>();
+
+ for (int i = 1; i < filteredList.size(); i++) {
+ // Get the current and last element
+ T thisElement = filteredList.get(i);
+ T lastElement = filteredList.get(i - 1);
+
+ // The list is sorted so if the last element name is the same as the current element name, the last element
+ // should be removed
+ if (((PfNameVersion)thisElement).getName().equals(((PfNameVersion)lastElement).getName())) {
+ filteredOutList.add(lastElement);
+ }
+ }
+
+ // We can now remove these elements
+ filteredList.removeAll(filteredOutList);
+
+ return filteredList;
+ }
+}
entry_schema:
type: string
data_types:
+ -
policy.data.affinityProperties_properties:
derived_from: tosca.nodes.Root
properties:
type: policy.data.distanceProperties_properties
required: true
data_types:
+ -
policy.data.distanceProperties_properties:
derived_from: tosca.nodes.Root
properties:
type: list
required: true
entry_schema:
- type:policy.data.flavorFeatures_properties
+ type: policy.data.flavorFeatures_properties
data_types:
+ -
policy.data.flavorFeatures_properties:
derived_from: tosca.nodes.Root
properties:
required: true
entry_schema:
type: policy.data.flavorProperties_properties
+ -
policy.data.directives_properties:
derived_from: tosca.nodes.Root
properties:
type: list
entry_schema:
type: policy.data.directives_attributes_properties
+ -
policy.data.directives_attributes_properties:
derived_from: tosca.nodes.Root
properties:
type: string
attribute_value:
type: string
+ -
policy.data.flavorProperties_properties:
derived_from: tosca.nodes.Root
properties:
required: true
entry_schema:
type: policy.data.hpa-feature-attributes_properties
+ -
policy.data.hpa-feature-attributes_properties:
derived_from: tosca.nodes.Root
properties:
type: policy.data.objectiveParameter_properties
required: true
data_types:
+ -
policy.data.objectiveParameter_properties:
derived_from: tosca.nodes.Root
properties:
type: list
required: false
entry_schema:
- - type:policy.data.pciProperties_properties
+ type: policy.data.pciProperties_properties
data_types:
+ -
policy.data.pciProperties_properties:
derived_from: tosca.nodes.Root
properties:
type: list
required: true
entry_schema:
- type:policy.data.queryProperties_properties
+ type: policy.data.queryProperties_properties
data_types:
+ -
policy.data.queryProperties_properties:
derived_from: tosca.nodes.Root
properties:
type: policy.data.properties_properties
required: true
data_types:
+ -
policy.data.properties_properties:
derived_from: tosca.nodes.Root
properties:
type: policy.data.capacityProperties_properties
required: true
data_types:
+ -
policy.data.capacityProperties_properties:
derived_from: tosca.nodes.Root
properties:
type: list
required: true
entry_schema:
- type:policy.data.vnfProperties_properties
+ type: policy.data.vnfProperties_properties
data_types:
+ -
policy.data.vnfProperties_properties:
derived_from: tosca.nodes.Root
properties:
*/
@Data
@NoArgsConstructor
-public class PdpGroup implements PfNameVersion {
+public class PdpGroup implements PfNameVersion, Comparable<PdpGroup> {
private String name;
private String version;
private String description;
this.properties = (source.properties == null ? null : new LinkedHashMap<>(source.properties));
this.pdpSubgroups = PfUtils.mapList(source.pdpSubgroups, PdpSubGroup::new);
}
+
+ @Override
+ public int compareTo(final PdpGroup other) {
+ return compareNameVersion(this, other);
+ }
}
import lombok.Data;
import lombok.NonNull;
-import org.onap.policy.models.base.PfObjectFiler;
+import org.apache.commons.lang3.ObjectUtils;
+import org.onap.policy.models.base.PfObjectFilter;
import org.onap.policy.models.pdp.enums.PdpState;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
/**
- * Filter class for searches for {@link PdpGroup} instances.
- * If any fields are null, they are ignored.
+ * Filter class for searches for {@link PdpGroup} instances. If any fields are null, they are ignored.
*
* @author Liam Fallon (liam.fallon@est.tech)
*/
@Builder
@Data
-public class PdpGroupFilter implements PfObjectFiler<PdpGroup> {
+public class PdpGroupFilter implements PfObjectFilter<PdpGroup> {
public static final String LATEST_VERSION = "LATEST";
// Regular expression
// Set regular expressions on fields to match policy names and versions
private ToscaPolicyIdentifier policy;
+ private PdpState pdpState;
+
@Override
public List<PdpGroup> filter(@NonNull final List<PdpGroup> originalList) {
// @formatter:off
- return originalList.stream()
- .filter(p -> name != null && p.getName() .matches(name))
- .filter(p -> version != null && p.getVersion().matches(version))
- .filter(p -> groupState != null && p.getPdpGroupState().equals(groupState))
+ List<PdpGroup> returnList = originalList.stream()
+ .filter(p -> filterOnRegexp(p.getName(), name))
+ .filter(p -> filterOnRegexp(p.getVersion(), version))
+ .filter(p -> ObjectUtils.compare(p.getPdpGroupState(), groupState) == 0)
+ .filter(p -> filterOnPdpType(p, pdpType))
+ .filter(p -> filterOnPolicyType(p, policyType))
+ .filter(p -> filterOnPolicy(p, policy))
.collect(Collectors.toList());
// @formatter:off
+
+ if (LATEST_VERSION.equals(version)) {
+ returnList = this.latestVersionFilter(returnList);
+ }
+
+ return returnList;
+ }
+
+ /**
+ * Filter PDP groups on PDP type.
+ *
+ * @param pdpGroup the PDP group to check
+ * @param pdpType the PDP type to check for
+ * @return true if the filter should let this PDP group through
+ */
+ private boolean filterOnPdpType(final PdpGroup pdpGroup, final String pdpType) {
+ if (pdpType == null) {
+ return true;
+ }
+
+ for (PdpSubGroup pdpSubGroup: pdpGroup.getPdpSubgroups()) {
+ if (pdpSubGroup.getPdpType().equals(pdpType)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Filter PDP groups on policy type.
+ *
+ * @param pdpGroup the PDP group to check
+ * @param policyTypeFilter the policy type regular expressions to check for
+ * @return true if the filter should let this PDP group through
+ */
+ private boolean filterOnPolicyType(final PdpGroup pdpGroup, final ToscaPolicyTypeIdentifier policyTypeFiler) {
+ if (policyTypeFiler == null) {
+ return true;
+ }
+
+ for (PdpSubGroup pdpSubGroup: pdpGroup.getPdpSubgroups()) {
+ for (ToscaPolicyTypeIdentifier foundPolicyType : pdpSubGroup.getSupportedPolicyTypes()) {
+ if (foundPolicyType.getName().matches(policyTypeFiler.getName())
+ && foundPolicyType.getVersion().matches(policyTypeFiler.getVersion())) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Filter PDP groups on policy.
+ *
+ * @param pdpGroup the PDP group to check
+ * @param policyFilter the policy regular expressions to check for
+ * @return true if the filter should let this PDP group through
+ */
+ private boolean filterOnPolicy(final PdpGroup pdpGroup, final ToscaPolicyIdentifier policyFiler) {
+ if (policyFiler == null) {
+ return true;
+ }
+
+ for (PdpSubGroup pdpSubGroup: pdpGroup.getPdpSubgroups()) {
+ for (ToscaPolicyIdentifier foundPolicy : pdpSubGroup.getPolicies()) {
+ if (foundPolicy.getName().matches(policyFiler.getName())
+ && foundPolicy.getVersion().matches(policyFiler.getVersion())) {
+ return true;
+ }
+ }
+ }
+
+ return false;
}
}
// verify with all values
orig.setDescription("my-descript");
orig.setName("my-name");
- orig.setVersion("my-version");
+ orig.setVersion("1.2.3");
orig.setDescription("my-description");
orig.setPdpGroupState(PdpState.SAFE);
props.put("key-B", "value-B");
orig.setProperties(props);
- assertEquals("PdpGroup(name=my-name, version=my-version, description=my-description, "
+ assertEquals("PdpGroup(name=my-name, version=1.2.3, description=my-description, "
+ "pdpGroupState=SAFE, properties={key-A=value-A, key-B=value-B}, "
+ "pdpSubgroups=[PdpSubGroup(pdpType=null, supportedPolicyTypes=[], policies=[], "
+ "currentInstanceCount=10, desiredInstanceCount=0, properties=null, pdpInstances=[]), "
--- /dev/null
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.models.provider.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+import com.google.gson.GsonBuilder;
+
+import java.util.Base64;
+import java.util.List;
+
+import lombok.NonNull;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.policy.common.utils.coder.StandardCoder;
+import org.onap.policy.common.utils.resources.ResourceUtils;
+import org.onap.policy.models.base.PfModelException;
+import org.onap.policy.models.provider.PolicyModelsProvider;
+import org.onap.policy.models.provider.PolicyModelsProviderFactory;
+import org.onap.policy.models.provider.PolicyModelsProviderParameters;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.yaml.snakeyaml.Yaml;
+
+/**
+ * Test persistence of monitoring policies to and from the database.
+ *
+ * @author Liam Fallon (liam.fallon@est.tech)
+ */
+public class PolicyTypePersistenceTest {
+ // Logger for this class
+ private static final Logger LOGGER = LoggerFactory.getLogger(PolicyTypePersistenceTest.class);
+
+ private StandardCoder standardCoder;
+
+ private PolicyModelsProvider databaseProvider;
+
+ // @formatter:off
+ private String[] policyTypeResourceNames = {
+ "policytypes/onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server.yaml",
+ "policytypes/onap.policies.optimization.AffinityPolicy.yaml",
+ "policytypes/onap.policies.optimization.DistancePolicy.yaml",
+ "policytypes/onap.policies.optimization.HpaPolicy.yaml",
+ "policytypes/onap.policies.optimization.OptimizationPolicy.yaml",
+ "policytypes/onap.policies.optimization.PciPolicy.yaml",
+ "policytypes/onap.policies.optimization.QueryPolicy.yaml",
+ "policytypes/onap.policies.optimization.SubscriberPolicy.yaml",
+ "policytypes/onap.policies.optimization.Vim_fit.yaml",
+ "policytypes/onap.policies.optimization.VnfPolicy.yaml",
+ "policytypes/onap.policy.monitoring.cdap.tca.hi.lo.app.yaml"
+ };
+ // @formatter:on
+
+ /**
+ * Initialize provider.
+ *
+ * @throws PfModelException on exceptions in the tests
+ */
+ @Before
+ public void setupParameters() throws PfModelException {
+ PolicyModelsProviderParameters parameters = new PolicyModelsProviderParameters();
+ parameters.setDatabaseUrl("jdbc:h2:mem:testdb");
+ parameters.setDatabaseUser("policy");
+ parameters.setDatabasePassword(Base64.getEncoder().encodeToString("P01icY".getBytes()));
+ parameters.setPersistenceUnit("ToscaConceptTest");
+
+ databaseProvider = new PolicyModelsProviderFactory().createPolicyModelsProvider(parameters);
+ }
+
+ /**
+ * Set up GSON.
+ */
+ @Before
+ public void setupGson() {
+ standardCoder = new StandardCoder();
+ }
+
+ @After
+ public void teardown() throws Exception {
+ databaseProvider.close();
+ }
+
+ @Test
+ public void testPolicyPersistence() {
+ try {
+ for (String policyTypeResourceName : policyTypeResourceNames) {
+ String policyTypeString = ResourceUtils.getResourceAsString(policyTypeResourceName);
+
+ if (policyTypeResourceName.endsWith("yaml")) {
+ testYamlStringPolicyTypePersistence(policyTypeString);
+ } else {
+ testJsonStringPolicyTypePersistence(policyTypeString);
+ }
+ }
+ } catch (Exception exc) {
+ LOGGER.warn("error processing policies", exc);
+ fail("test should not throw an exception");
+ }
+ }
+
+ private void testYamlStringPolicyTypePersistence(final String policyTypeString) throws Exception {
+ Object yamlObject = new Yaml().load(policyTypeString);
+ String yamlAsJsonString = new GsonBuilder().setPrettyPrinting().create().toJson(yamlObject);
+
+ testJsonStringPolicyTypePersistence(yamlAsJsonString);
+ }
+
+ /**
+ * Check persistence of a policy.
+ *
+ * @param policyTypeString the policy as a string
+ * @throws Exception any exception thrown
+ */
+ public void testJsonStringPolicyTypePersistence(@NonNull final String policyTypeString) throws Exception {
+ ToscaServiceTemplate serviceTemplate = standardCoder.decode(policyTypeString, ToscaServiceTemplate.class);
+
+ assertNotNull(serviceTemplate);
+ ToscaPolicyType inPolicyType = serviceTemplate.getPolicyTypes().get(0).values().iterator().next();
+
+ databaseProvider.createPolicyTypes(serviceTemplate);
+
+ List<ToscaPolicyType> policyTypeList =
+ databaseProvider.getPolicyTypeList(inPolicyType.getName(), inPolicyType.getVersion());
+
+ assertEquals(1, policyTypeList.size());
+ assertEquals(inPolicyType.getName(), policyTypeList.get(0).getName());
+ }
+}
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.NonNull;
+
import org.onap.policy.models.base.PfNameVersion;
/**
}
}
}
-
}
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@ToString(callSuper = true)
-public class ToscaPolicy extends ToscaEntity {
+public class ToscaPolicy extends ToscaEntity implements Comparable<ToscaPolicy> {
private String type;
private String typeVersion;
public ToscaPolicyTypeIdentifier getTypeIdentifier() {
return new ToscaPolicyTypeIdentifier(getType(), getTypeVersion());
}
+
+ @Override
+ public int compareTo(final ToscaPolicy other) {
+ return compareNameVersion(this, other);
+ }
}
import lombok.Data;
import lombok.NonNull;
-import org.onap.policy.models.base.PfObjectFiler;
+import org.onap.policy.models.base.PfObjectFilter;
/**
* Filter class for searches for {@link ToscaPolicy} instances.
*/
@Builder
@Data
-public class ToscaPolicyFilter implements PfObjectFiler<ToscaPolicy> {
+public class ToscaPolicyFilter implements PfObjectFilter<ToscaPolicy> {
public static final String LATEST_VERSION = "LATEST";
// Regular expression
private String version;
// Regular expression
- private String policyTypeName;
+ private String type;
// Regular Expression, set to LATEST_VERRSION to get the latest version
- private String policyTypeVersion;
+ private String typeVersion;
@Override
public List<ToscaPolicy> filter(@NonNull final List<ToscaPolicy> originalList) {
// @formatter:off
- return originalList.stream()
- .filter(p -> name != null && p.getName() .matches(name))
- .filter(p -> version != null && p.getVersion() .matches(version))
- .filter(p -> policyTypeName != null && p.getType() .matches(policyTypeName))
- .filter(p -> policyTypeVersion != null && p.getTypeVersion().matches(policyTypeVersion))
+ List<ToscaPolicy> returnList = originalList.stream()
+ .filter(p -> filterOnRegexp(p.getName(), name))
+ .filter(p -> filterOnRegexp(p.getVersion(), version))
+ .filter(p -> filterOnRegexp(p.getType(), type))
+ .filter(p -> filterOnRegexp(p.getTypeVersion(), typeVersion))
.collect(Collectors.toList());
// @formatter:off
+
+ if (LATEST_VERSION.equals(version)) {
+ return this.latestVersionFilter(returnList);
+ }
+ else {
+ return returnList;
+ }
}
}
@Data
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
-public class ToscaPolicyType extends ToscaEntity {
+public class ToscaPolicyType extends ToscaEntity implements Comparable<ToscaPolicyType> {
private Map<String, ToscaProperty> properties;
+
+ @Override
+ public int compareTo(final ToscaPolicyType other) {
+ return compareNameVersion(this, other);
+ }
}
import lombok.Data;
import lombok.NonNull;
-import org.onap.policy.models.base.PfObjectFiler;
+import org.onap.policy.models.base.PfObjectFilter;
/**
* Filter class for searches for {@link ToscaPolicyType} instances.
*/
@Builder
@Data
-public class ToscaPolicyTypeFilter implements PfObjectFiler<ToscaPolicyType> {
+public class ToscaPolicyTypeFilter implements PfObjectFilter<ToscaPolicyType> {
public static final String LATEST_VERSION = "LATEST";
// Regular expression
public List<ToscaPolicyType> filter(@NonNull final List<ToscaPolicyType> originalList) {
// @formatter:off
- return originalList.stream()
- .filter(p -> name != null && p.getName() .matches(name))
- .filter(p -> version != null && p.getVersion().matches(version))
+ List<ToscaPolicyType> returnList = originalList.stream()
+ .filter(p -> filterOnRegexp(p.getName(), name))
+ .filter(p -> filterOnRegexp(p.getVersion(), version))
.collect(Collectors.toList());
// @formatter:off
+
+ if (LATEST_VERSION.equals(version)) {
+ return this.latestVersionFilter(returnList);
+ }
+ else {
+ return returnList;
+ }
}
}
* @return the policies found
* @throws PfModelException on errors getting policies
*/
- public ToscaServiceTemplate getPolicies(@NonNull final PfDao dao, @NonNull final String name,
- @NonNull final String version) throws PfModelException {
+ public ToscaServiceTemplate getPolicies(@NonNull final PfDao dao, final String name, final String version)
+ throws PfModelException {
return new SimpleToscaProvider().getPolicies(dao, name, version).toAuthorative();
}
@Override
public void fromAuthorative(T toscaEntity) {
- key = new PfConceptKey();
+ key = new PfConceptKey();
if (toscaEntity.getName() != null) {
key.setName(toscaEntity.getName());
// CHeck if the derived from field contains a name-version ID
if (toscaEntity.getDerivedFrom().contains(":")) {
derivedFrom = new PfConceptKey(toscaEntity.getDerivedFrom());
- }
- else {
+ } else {
derivedFrom = new PfConceptKey(toscaEntity.getDerivedFrom(), PfKey.NULL_KEY_VERSION);
}
}
import javax.persistence.Entity;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
+import javax.persistence.Lob;
import javax.persistence.Table;
import lombok.Data;
private PfConceptKey type;
@ElementCollection
- @Column(length = 10000)
+ @Lob
private Map<String, String> properties;
@ElementCollection
import javax.persistence.Entity;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
+import javax.persistence.Lob;
import javax.persistence.Table;
import lombok.Data;
private static final long serialVersionUID = -563659852901842616L;
@ElementCollection
+ @Lob
private Map<String, JpaToscaProperty> properties;
@ElementCollection
private String defaultValue;
@Column
- @NonNull
private Status status = Status.SUPPORTED;
@ElementCollection
tp.getConstraints().remove(null);
assertTrue(tp.validate(new PfValidationResult()).isValid());
- try {
- tp.setStatus(null);
- fail("test should throw an exception");
- } catch (Exception exc) {
- assertEquals("status is marked @NonNull but is null", exc.getMessage());
- }
-
try {
tp.validate(null);
fail("test should throw an exception");