import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
assertEquals(0, someKey0.compareTo(someKey0));
assertEquals(-36, someKey0.compareTo(new DummyPfKey()));
- assertNotEquals(someKey0, null);
- assertEquals(someKey0, (Object) someKey0);
- assertNotEquals(someKey0, (Object) new DummyPfKey());
-
MyKey someKey8 = new MyKey();
someKey8.setVersion(VERSION001);
assertFalse(someKey8.isNullKey());
ToscaEntityFilter.<ToscaPolicyType>builder().build());
ToscaPolicyType gotPolicyType = gotServiceTemplate.getPolicyTypes().get(policyTypeKey.getName());
- assertEquals(true, beforePolicyType.getName().equals(gotPolicyType.getName()));
- assertEquals(0, ObjectUtils.compare(beforePolicyType.getDescription(), gotPolicyType.getDescription()));
+ checkEqualsNameDescription(beforePolicyType, gotPolicyType);
gotServiceTemplate = new AuthorativeToscaProvider().getFilteredPolicyTypes(pfDao,
ToscaEntityFilter.<ToscaPolicyType>builder().name(policyTypeKey.getName()).build());
gotPolicyType = gotServiceTemplate.getPolicyTypes().get(policyTypeKey.getName());
- assertEquals(true, beforePolicyType.getName().equals(gotPolicyType.getName()));
- assertEquals(0, ObjectUtils.compare(beforePolicyType.getDescription(), gotPolicyType.getDescription()));
+ checkEqualsNameDescription(beforePolicyType, gotPolicyType);
gotServiceTemplate = new AuthorativeToscaProvider().getFilteredPolicyTypes(pfDao, ToscaEntityFilter
.<ToscaPolicyType>builder().name(policyTypeKey.getName()).version(VERSION_001).build());
gotPolicyType = gotServiceTemplate.getPolicyTypes().get(policyTypeKey.getName());
- assertEquals(true, beforePolicyType.getName().equals(gotPolicyType.getName()));
- assertEquals(0, ObjectUtils.compare(beforePolicyType.getDescription(), gotPolicyType.getDescription()));
+ checkEqualsNameDescription(beforePolicyType, gotPolicyType);
List<ToscaPolicyType> gotPolicyTypeList =
new AuthorativeToscaProvider().getPolicyTypeList(pfDao, POLICY_NO_VERSION, VERSION_001);
assertEquals(true, beforePolicyType.getName().equals(gotPolicyType.getName()));
}
+ private void checkEqualsNameDescription(ToscaPolicyType beforePolicyType, ToscaPolicyType gotPolicyType) {
+ assertEquals(beforePolicyType.getName(), gotPolicyType.getName());
+ assertEquals(0, ObjectUtils.compare(beforePolicyType.getDescription(), gotPolicyType.getDescription()));
+ }
+
@Test
public void testPolicyTypesCreate() throws Exception {
assertThatThrownBy(() -> {
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 Nordix Foundation.
+ * Copyright (C) 2019-2021 Nordix Foundation.
* Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
assertThatThrownBy(() -> new JpaToscaDataType((JpaToscaDataType) null))
.isInstanceOf(NullPointerException.class);
+ }
+ @Test
+ public void testDataTypeProperties() {
PfConceptKey dtKey = new PfConceptKey("tdt", VERSION_001);
JpaToscaDataType tdt = new JpaToscaDataType(dtKey);
assertEquals(tdtClone0, tdt);
assertFalse(new JpaToscaDataType().validate("").isValid());
+ validateJpaToscaDataTypeOperations(tdt);
+
+ assertThatThrownBy(() -> {
+ tdt.validate(null);
+ }).hasMessageMatching("fieldName is marked .*on.*ull but is null");
+ }
+
+ private void validateJpaToscaDataTypeOperations(JpaToscaDataType tdt) {
assertTrue(tdt.validate("").isValid());
tdt.getConstraints().add(null);
assertFalse(tdt.validate("").isValid());
tdt.getProperties().remove(null);
assertTrue(tdt.validate("").isValid());
+ }
- assertThatThrownBy(() -> {
- tdt.validate(null);
- }).hasMessageMatching("fieldName is marked .*on.*ull but is null");
-
+ @Test
+ public void testDataTypeConstraints() {
ToscaDataType dat = new ToscaDataType();
dat.setName("name");
dat.setVersion("1.2.3");
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 Nordix Foundation.
+ * Copyright (C) 2019-2021 Nordix Foundation.
* Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
assertThatThrownBy(() -> new JpaToscaDataTypes(null, new TreeMap<PfConceptKey, JpaToscaDataType>()))
.hasMessageMatching(KEY_IS_NULL);
+ }
+ @Test
+ public void testDerivedDataTypes() {
List<Map<String, ToscaDataType>> dtMapList = new ArrayList<>();
dtMapList.add(new LinkedHashMap<>());
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 Nordix Foundation.
+ * Copyright (C) 2019-2021 Nordix Foundation.
* Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
assertThatThrownBy(() -> new JpaToscaEventFilter((JpaToscaEventFilter) null))
.isInstanceOf(NullPointerException.class);
+ }
+ @Test
+ public void testEventFilter() {
PfConceptKey efParentKey = new PfConceptKey("tParentKey", VERSION_001);
PfReferenceKey efKey = new PfReferenceKey(efParentKey, "trigger0");
PfConceptKey nodeKey = new PfConceptKey("tParentKey", VERSION_001);
assertEquals(A_CAPABILITY, tef.getCapability());
JpaToscaEventFilter tdtClone0 = new JpaToscaEventFilter(tef);
- assertEquals(tef, tdtClone0);
- assertEquals(0, tef.compareTo(tdtClone0));
+ checkEqualsEventFilter(tef, tdtClone0);
JpaToscaEventFilter tdtClone1 = new JpaToscaEventFilter(tef);
- assertEquals(tef, tdtClone1);
- assertEquals(0, tef.compareTo(tdtClone1));
+ checkEqualsEventFilter(tef, tdtClone1);
assertEquals(-1, tef.compareTo(null));
assertEquals(0, tef.compareTo(tef));
assertEquals(2, tef.getKeys().size());
assertEquals(2, new JpaToscaEventFilter().getKeys().size());
+ }
+
+ private void checkEqualsEventFilter(JpaToscaEventFilter tef1, JpaToscaEventFilter tef2) {
+ assertEquals(tef1, tef2);
+ assertEquals(0, tef1.compareTo(tef2));
+ }
+
+ @Test
+ public void testValidationEventFilter() {
+ PfConceptKey efParentKey = new PfConceptKey("tParentKey", VERSION_001);
+ PfReferenceKey efKey = new PfReferenceKey(efParentKey, "trigger0");
+ PfConceptKey nodeKey = new PfConceptKey("tParentKey", VERSION_001);
+ JpaToscaEventFilter tef = new JpaToscaEventFilter(efKey, nodeKey);
+
+ JpaToscaEventFilter tdtClone0 = new JpaToscaEventFilter(tef);
new JpaToscaEventFilter().clean();
tef.clean();
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 Nordix Foundation.
+ * Copyright (C) 2019-2021 Nordix Foundation.
* Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
assertThatThrownBy(() -> new JpaToscaTopologyTemplate((JpaToscaTopologyTemplate) null))
.isInstanceOf(NullPointerException.class);
+ assertThatThrownBy(() -> new JpaToscaTopologyTemplate((JpaToscaTopologyTemplate) null))
+ .isInstanceOf(NullPointerException.class);
+ }
+
+ @Test
+ public void testTopologyTemplates() {
PfReferenceKey tttKey = new PfReferenceKey("tst", VERSION_001, "ttt");
JpaToscaTopologyTemplate ttt = new JpaToscaTopologyTemplate(tttKey);
ttt.setPolicies(policies);
JpaToscaTopologyTemplate tttClone0 = new JpaToscaTopologyTemplate(ttt);
- assertEquals(ttt, tttClone0);
- assertEquals(0, ttt.compareTo(tttClone0));
+ checkEqualsTopologyTemplate(ttt, tttClone0);
JpaToscaTopologyTemplate tttClone1 = new JpaToscaTopologyTemplate(ttt);
- assertEquals(ttt, tttClone1);
- assertEquals(0, ttt.compareTo(tttClone1));
+ checkEqualsTopologyTemplate(ttt, tttClone1);
assertEquals(-1, ttt.compareTo(null));
assertEquals(0, ttt.compareTo(ttt));
otherDt.setPolicies(policies);
assertEquals(0, ttt.compareTo(otherDt));
- assertThatThrownBy(() -> new JpaToscaTopologyTemplate((JpaToscaTopologyTemplate) null))
- .isInstanceOf(NullPointerException.class);
-
assertEquals(4, ttt.getKeys().size());
assertEquals(1, new JpaToscaTopologyTemplate().getKeys().size());
+ }
+
+ @Test
+ public void testTopologyTemplateValidation() {
+ PfReferenceKey tttKey = new PfReferenceKey("tst", VERSION_001, "ttt");
+ JpaToscaTopologyTemplate ttt = new JpaToscaTopologyTemplate(tttKey);
+
+ JpaToscaTopologyTemplate tttClone0 = new JpaToscaTopologyTemplate(ttt);
new JpaToscaTopologyTemplate().clean();
ttt.clean();
assertThatThrownBy(() -> ttt.validate(null)).hasMessageMatching("fieldName is marked .*on.*ull but is null");
}
+
+ private void checkEqualsTopologyTemplate(JpaToscaTopologyTemplate ttt1, JpaToscaTopologyTemplate ttt2) {
+ assertEquals(ttt1, ttt2);
+ assertEquals(0, ttt1.compareTo(ttt2));
+ }
}
.hasMessageMatching("eventType is marked .*on.*ull but is null");
assertThatThrownBy(() -> new JpaToscaTrigger((JpaToscaTrigger) null)).isInstanceOf(NullPointerException.class);
+ }
+ @Test
+ public void testTriggerConstraints() {
PfConceptKey tparentKey = new PfConceptKey("tParentKey", VERSION_001);
PfReferenceKey tkey = new PfReferenceKey(tparentKey, "trigger0");
JpaToscaTrigger tdt = new JpaToscaTrigger(tkey, EVENT_TYPE, ACTION);
assertEquals(A_METHOD, tdt.getMethod());
JpaToscaTrigger tdtClone0 = new JpaToscaTrigger(tdt);
- assertEquals(tdt, tdtClone0);
- assertEquals(0, tdt.compareTo(tdtClone0));
+ checkEqualsToscaTriggers(tdt, tdtClone0);
JpaToscaTrigger tdtClone1 = new JpaToscaTrigger(tdt);
- assertEquals(tdt, tdtClone1);
- assertEquals(0, tdt.compareTo(tdtClone1));
+ checkEqualsToscaTriggers(tdt, tdtClone1);
assertEquals(-1, tdt.compareTo(null));
assertEquals(0, tdt.compareTo(tdt));
assertEquals(4, tdt.getKeys().size());
assertEquals(1, new JpaToscaTrigger().getKeys().size());
+ }
+
+ @Test
+ public void testCloneToscaTrigger() {
+ PfConceptKey tparentKey = new PfConceptKey("tParentKey", VERSION_001);
+ PfReferenceKey tkey = new PfReferenceKey(tparentKey, "trigger0");
+ JpaToscaTrigger tdt = new JpaToscaTrigger(tkey, EVENT_TYPE, ACTION);
+
+ JpaToscaTrigger tdtClone0 = new JpaToscaTrigger(tdt);
new JpaToscaTrigger().clean();
tdt.clean();
assertThatThrownBy(() -> tdt.validate(null)).hasMessageMatching("fieldName is marked .*on.*ull but is null");
}
+
+ private void checkEqualsToscaTriggers(JpaToscaTrigger tdt1, JpaToscaTrigger tdt2) {
+ assertEquals(tdt1, tdt2);
+ assertEquals(0, tdt1.compareTo(tdt2));
+ }
}
}
@Test
- public void testNonNulls() {
+ public void testNonNullsDataType() {
assertThatThrownBy(() -> {
new SimpleToscaProvider().getServiceTemplate(null);
}).hasMessageMatching(DAO_IS_NULL);
assertThatThrownBy(() -> {
new SimpleToscaProvider().deleteDataType(pfDao, null);
}).hasMessageMatching("^dataTypeKey is marked .*on.*ull but is null$");
+ }
+ @Test
+ public void testNotNullsPolicyTypes() {
assertThatThrownBy(() -> {
new SimpleToscaProvider().getPolicyTypes(null, null, null);
}).hasMessageMatching(DAO_IS_NULL);