diff options
author | liamfallon <liam.fallon@est.tech> | 2020-05-10 15:53:46 +0100 |
---|---|---|
committer | liamfallon <liam.fallon@est.tech> | 2020-05-10 22:38:13 +0100 |
commit | 52170568d84bc50ce0119249d387bbf342c2bc7a (patch) | |
tree | dc73cd9d59624b2c0270c0fbaa7968ac4dad879b /models-tosca/src/test/java | |
parent | 59278e17a3911518c5e3601b6a38bfbbcbcf0fc8 (diff) |
Policy DB contents removed on DB deadlock
When a DB deadlock occurs, the DB contents can sometimes be deleted
becasue the DB removes the Service Template object and recreates a new
one in two separate DB transactions.
This change makes sure that the object remove and re-create is in a
sngle DB transaction, so the operation will either happen or not happen
so the DB will not be cleared.
Legacy policy handling must also use the SimpleToscaProvider rather than
accessing the DB directly, as SimpleToscaProvider keeps the DB structure
correct.
Issue-ID: POLICY-2548
Change-Id: I263a41cd1d8bec5d7b421045b3b14aad6e6c66d3
Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'models-tosca/src/test/java')
4 files changed, 61 insertions, 54 deletions
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTypeTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTypeTest.java index 3f0d9e2a5..22b9ab04d 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTypeTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTypeTest.java @@ -133,7 +133,7 @@ public class AuthorativeToscaProviderPolicyTypeTest { assertNotNull(toscaServiceTemplate); ToscaServiceTemplate createdServiceTemplate = - new AuthorativeToscaProvider().createPolicyTypes(pfDao, toscaServiceTemplate); + new AuthorativeToscaProvider().createPolicyTypes(pfDao, toscaServiceTemplate); PfConceptKey policyTypeKey = new PfConceptKey(POLICY_NO_VERSION_VERSION1); @@ -142,15 +142,15 @@ public class AuthorativeToscaProviderPolicyTypeTest { assertEquals(true, beforePolicyType.getName().equals(createdPolicyType.getName())); assertEquals(0, ObjectUtils.compare(beforePolicyType.getDescription(), createdPolicyType.getDescription())); - ToscaServiceTemplate gotServiceTemplate = new AuthorativeToscaProvider().getPolicyTypes(pfDao, - policyTypeKey.getName(), policyTypeKey.getVersion()); + ToscaServiceTemplate gotServiceTemplate = + new AuthorativeToscaProvider().getPolicyTypes(pfDao, policyTypeKey.getName(), policyTypeKey.getVersion()); ToscaPolicyType gotPolicyType = gotServiceTemplate.getPolicyTypes().get(policyTypeKey.getName()); assertEquals(true, beforePolicyType.getName().equals(gotPolicyType.getName())); assertEquals(0, ObjectUtils.compare(beforePolicyType.getDescription(), createdPolicyType.getDescription())); List<ToscaPolicyType> gotPolicyTypeList = - new AuthorativeToscaProvider().getPolicyTypeList(pfDao, POLICY_NO_VERSION, VERSION_001); + new AuthorativeToscaProvider().getPolicyTypeList(pfDao, POLICY_NO_VERSION, VERSION_001); assertEquals(2, gotPolicyTypeList.size()); assertEquals(true, beforePolicyType.getName().equals(gotPolicyType.getName())); @@ -166,8 +166,9 @@ public class AuthorativeToscaProviderPolicyTypeTest { assertEquals(2, gotPolicyTypeList.size()); assertEquals(true, beforePolicyType.getName().equals(gotPolicyType.getName())); - assertThatThrownBy(() -> new AuthorativeToscaProvider().getPolicyTypeList(new DefaultPfDao(), POLICY_NO_VERSION, - VERSION_001)).hasMessageContaining("Policy Framework DAO has not been initialized"); + assertThatThrownBy( + () -> new AuthorativeToscaProvider().getPolicyTypeList(new DefaultPfDao(), POLICY_NO_VERSION, VERSION_001)) + .hasMessageContaining("Policy Framework DAO has not been initialized"); assertTrue(new AuthorativeToscaProvider().getPolicyTypeList(pfDao, "i.dont.Exist", VERSION_001).isEmpty()); } @@ -199,18 +200,17 @@ public class AuthorativeToscaProviderPolicyTypeTest { }).hasMessageMatching("^filter is marked .*on.*ull but is null$"); assertThatThrownBy(() -> new AuthorativeToscaProvider().getFilteredPolicyTypeList(new DefaultPfDao(), - ToscaPolicyTypeFilter.builder().name("i.dont.Exist").build())) - .hasMessageContaining("Policy Framework DAO has not been initialized"); + ToscaPolicyTypeFilter.builder().name("i.dont.Exist").build())) + .hasMessageContaining("Policy Framework DAO has not been initialized"); assertTrue(new AuthorativeToscaProvider() - .getFilteredPolicyTypeList(pfDao, ToscaPolicyTypeFilter.builder().name("i.dont.Exist").build()) - .isEmpty()); + .getFilteredPolicyTypeList(pfDao, ToscaPolicyTypeFilter.builder().name("i.dont.Exist").build()).isEmpty()); ToscaServiceTemplate toscaServiceTemplate = standardCoder.decode(yamlAsJsonString, ToscaServiceTemplate.class); assertNotNull(toscaServiceTemplate); ToscaServiceTemplate createdServiceTemplate = - new AuthorativeToscaProvider().createPolicyTypes(pfDao, toscaServiceTemplate); + new AuthorativeToscaProvider().createPolicyTypes(pfDao, toscaServiceTemplate); PfConceptKey policyTypeKey = new PfConceptKey(POLICY_NO_VERSION_VERSION1); @@ -220,48 +220,48 @@ public class AuthorativeToscaProviderPolicyTypeTest { assertEquals(0, ObjectUtils.compare(beforePolicyType.getDescription(), createdPolicyType.getDescription())); ToscaServiceTemplate gotServiceTemplate = - new AuthorativeToscaProvider().getFilteredPolicyTypes(pfDao, ToscaPolicyTypeFilter.builder().build()); + new AuthorativeToscaProvider().getFilteredPolicyTypes(pfDao, ToscaPolicyTypeFilter.builder().build()); ToscaPolicyType gotPolicyType = gotServiceTemplate.getPolicyTypes().get(policyTypeKey.getName()); assertEquals(true, beforePolicyType.getName().equals(gotPolicyType.getName())); assertEquals(0, ObjectUtils.compare(beforePolicyType.getDescription(), gotPolicyType.getDescription())); gotServiceTemplate = new AuthorativeToscaProvider().getFilteredPolicyTypes(pfDao, - ToscaPolicyTypeFilter.builder().name(policyTypeKey.getName()).build()); + ToscaPolicyTypeFilter.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())); gotServiceTemplate = new AuthorativeToscaProvider().getFilteredPolicyTypes(pfDao, - ToscaPolicyTypeFilter.builder().name(policyTypeKey.getName()).version(VERSION_001).build()); + ToscaPolicyTypeFilter.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())); List<ToscaPolicyType> gotPolicyTypeList = - new AuthorativeToscaProvider().getPolicyTypeList(pfDao, POLICY_NO_VERSION, VERSION_001); + new AuthorativeToscaProvider().getPolicyTypeList(pfDao, POLICY_NO_VERSION, VERSION_001); assertEquals(2, gotPolicyTypeList.size()); assertEquals(true, beforePolicyType.getName().equals(gotPolicyType.getName())); - gotPolicyTypeList = new AuthorativeToscaProvider().getFilteredPolicyTypeList(pfDao, - ToscaPolicyTypeFilter.builder().build()); + gotPolicyTypeList = + new AuthorativeToscaProvider().getFilteredPolicyTypeList(pfDao, ToscaPolicyTypeFilter.builder().build()); assertEquals(2, gotPolicyTypeList.size()); assertEquals(true, beforePolicyType.getName().equals(gotPolicyType.getName())); gotPolicyTypeList = new AuthorativeToscaProvider().getFilteredPolicyTypeList(pfDao, - ToscaPolicyTypeFilter.builder().name(policyTypeKey.getName()).build()); + ToscaPolicyTypeFilter.builder().name(policyTypeKey.getName()).build()); assertEquals(1, gotPolicyTypeList.size()); assertEquals(true, beforePolicyType.getName().equals(gotPolicyType.getName())); gotPolicyTypeList = new AuthorativeToscaProvider().getFilteredPolicyTypeList(pfDao, - ToscaPolicyTypeFilter.builder().name(policyTypeKey.getName()).version(VERSION_001).build()); + ToscaPolicyTypeFilter.builder().name(policyTypeKey.getName()).version(VERSION_001).build()); assertEquals(1, gotPolicyTypeList.size()); assertEquals(true, beforePolicyType.getName().equals(gotPolicyType.getName())); gotPolicyTypeList = new AuthorativeToscaProvider().getFilteredPolicyTypeList(pfDao, - ToscaPolicyTypeFilter.builder().version("1.0.0").build()); + ToscaPolicyTypeFilter.builder().version("1.0.0").build()); assertEquals(1, gotPolicyTypeList.size()); assertEquals(true, beforePolicyType.getName().equals(gotPolicyType.getName())); } @@ -294,7 +294,7 @@ public class AuthorativeToscaProviderPolicyTypeTest { assertNotNull(toscaServiceTemplate); ToscaServiceTemplate createdServiceTemplate = - new AuthorativeToscaProvider().createPolicyTypes(pfDao, toscaServiceTemplate); + new AuthorativeToscaProvider().createPolicyTypes(pfDao, toscaServiceTemplate); PfConceptKey policyTypeKey = new PfConceptKey(POLICY_NO_VERSION_VERSION1); @@ -326,7 +326,7 @@ public class AuthorativeToscaProviderPolicyTypeTest { assertNotNull(toscaServiceTemplate); ToscaServiceTemplate createdServiceTemplate = - new AuthorativeToscaProvider().createPolicyTypes(pfDao, toscaServiceTemplate); + new AuthorativeToscaProvider().createPolicyTypes(pfDao, toscaServiceTemplate); PfConceptKey policyTypeKey = new PfConceptKey(POLICY_NO_VERSION_VERSION1); @@ -336,7 +336,7 @@ public class AuthorativeToscaProviderPolicyTypeTest { assertEquals(0, ObjectUtils.compare(beforePolicyType.getDescription(), createdPolicyType.getDescription())); ToscaServiceTemplate updatedServiceTemplate = - new AuthorativeToscaProvider().updatePolicyTypes(pfDao, toscaServiceTemplate); + new AuthorativeToscaProvider().updatePolicyTypes(pfDao, toscaServiceTemplate); ToscaPolicyType updatedPolicy = updatedServiceTemplate.getPolicyTypes().get(policyTypeKey.getName()); assertEquals(true, beforePolicyType.getName().equals(updatedPolicy.getName())); @@ -377,7 +377,7 @@ public class AuthorativeToscaProviderPolicyTypeTest { assertNotNull(toscaServiceTemplate); ToscaServiceTemplate createdServiceTemplate = - new AuthorativeToscaProvider().createPolicyTypes(pfDao, toscaServiceTemplate); + new AuthorativeToscaProvider().createPolicyTypes(pfDao, toscaServiceTemplate); PfConceptKey policyTypeKey = new PfConceptKey(POLICY_NO_VERSION_VERSION1); @@ -386,8 +386,8 @@ public class AuthorativeToscaProviderPolicyTypeTest { assertEquals(true, beforePolicyType.getName().equals(createdPolicyType.getName())); assertEquals(0, ObjectUtils.compare(beforePolicyType.getDescription(), createdPolicyType.getDescription())); - ToscaServiceTemplate deletedServiceTemplate = new AuthorativeToscaProvider().deletePolicyType(pfDao, - policyTypeKey.getName(), policyTypeKey.getVersion()); + ToscaServiceTemplate deletedServiceTemplate = + new AuthorativeToscaProvider().deletePolicyType(pfDao, policyTypeKey.getName(), policyTypeKey.getVersion()); ToscaPolicyType deletedPolicy = deletedServiceTemplate.getPolicyTypes().get(policyTypeKey.getName()); assertEquals(true, beforePolicyType.getName().equals(deletedPolicy.getName())); diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/provider/LegacyProvider4LegacyOperationalTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/provider/LegacyProvider4LegacyOperationalTest.java index 4d0fd6fd6..42996c3a1 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/provider/LegacyProvider4LegacyOperationalTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/provider/LegacyProvider4LegacyOperationalTest.java @@ -112,12 +112,12 @@ public class LegacyProvider4LegacyOperationalTest { assertThatThrownBy(() -> { new LegacyProvider().getOperationalPolicy(pfDao, "I Dont Exist", null); - }).hasMessage("no policy found for policy: I Dont Exist:null"); + }).hasMessage("service template not found in database"); createPolicyTypes(); LegacyOperationalPolicy originalLop = - standardCoder.decode(ResourceUtils.getResourceAsString(VCPE_INPUT_JSON), LegacyOperationalPolicy.class); + standardCoder.decode(ResourceUtils.getResourceAsString(VCPE_INPUT_JSON), LegacyOperationalPolicy.class); assertNotNull(originalLop); @@ -126,7 +126,7 @@ public class LegacyProvider4LegacyOperationalTest { assertEquals(originalLop, createdLop); LegacyOperationalPolicy gotLop = - new LegacyProvider().getOperationalPolicy(pfDao, originalLop.getPolicyId(), null); + new LegacyProvider().getOperationalPolicy(pfDao, originalLop.getPolicyId(), null); assertEquals(gotLop, originalLop); @@ -137,7 +137,7 @@ public class LegacyProvider4LegacyOperationalTest { LegacyOperationalPolicy createdLopV2 = new LegacyProvider().createOperationalPolicy(pfDao, originalLop); LegacyOperationalPolicy gotLopV2 = - new LegacyProvider().getOperationalPolicy(pfDao, originalLop.getPolicyId(), null); + new LegacyProvider().getOperationalPolicy(pfDao, originalLop.getPolicyId(), null); assertEquals(gotLopV2, createdLopV2); } @@ -158,7 +158,7 @@ public class LegacyProvider4LegacyOperationalTest { createPolicyTypes(); LegacyOperationalPolicy originalLop = - standardCoder.decode(ResourceUtils.getResourceAsString(VCPE_INPUT_JSON), LegacyOperationalPolicy.class); + standardCoder.decode(ResourceUtils.getResourceAsString(VCPE_INPUT_JSON), LegacyOperationalPolicy.class); assertNotNull(originalLop); @@ -167,7 +167,7 @@ public class LegacyProvider4LegacyOperationalTest { assertEquals(originalLop, createdLop); LegacyOperationalPolicy gotLop = - new LegacyProvider().getOperationalPolicy(pfDao, originalLop.getPolicyId(), null); + new LegacyProvider().getOperationalPolicy(pfDao, originalLop.getPolicyId(), null); assertEquals(gotLop, originalLop); @@ -198,7 +198,7 @@ public class LegacyProvider4LegacyOperationalTest { createPolicyTypes(); LegacyOperationalPolicy originalLop = - standardCoder.decode(ResourceUtils.getResourceAsString(VCPE_INPUT_JSON), LegacyOperationalPolicy.class); + standardCoder.decode(ResourceUtils.getResourceAsString(VCPE_INPUT_JSON), LegacyOperationalPolicy.class); assertNotNull(originalLop); @@ -206,7 +206,7 @@ public class LegacyProvider4LegacyOperationalTest { assertEquals(originalLop, createdLop); LegacyOperationalPolicy gotLop = - new LegacyProvider().getOperationalPolicy(pfDao, originalLop.getPolicyId(), null); + new LegacyProvider().getOperationalPolicy(pfDao, originalLop.getPolicyId(), null); assertEquals(gotLop, originalLop); originalLop.setContent("Some New Content"); @@ -214,7 +214,7 @@ public class LegacyProvider4LegacyOperationalTest { assertEquals(originalLop, updatedLop); LegacyOperationalPolicy gotUpdatedLop = - new LegacyProvider().getOperationalPolicy(pfDao, originalLop.getPolicyId(), null); + new LegacyProvider().getOperationalPolicy(pfDao, originalLop.getPolicyId(), null); assertEquals(gotUpdatedLop, originalLop); assertEquals("Some New Content", gotUpdatedLop.getContent()); } @@ -252,12 +252,12 @@ public class LegacyProvider4LegacyOperationalTest { assertThatThrownBy(() -> { new LegacyProvider().deleteOperationalPolicy(pfDao, "IDontExist", "0"); - }).hasMessage("no policy found for policy: IDontExist:0"); + }).hasMessage("service template not found in database"); createPolicyTypes(); LegacyOperationalPolicy originalLop = - standardCoder.decode(ResourceUtils.getResourceAsString(VCPE_INPUT_JSON), LegacyOperationalPolicy.class); + standardCoder.decode(ResourceUtils.getResourceAsString(VCPE_INPUT_JSON), LegacyOperationalPolicy.class); assertNotNull(originalLop); @@ -265,7 +265,7 @@ public class LegacyProvider4LegacyOperationalTest { assertEquals(originalLop, createdLop); LegacyOperationalPolicy gotLop = - new LegacyProvider().getOperationalPolicy(pfDao, originalLop.getPolicyId(), null); + new LegacyProvider().getOperationalPolicy(pfDao, originalLop.getPolicyId(), null); assertEquals(gotLop, originalLop); @@ -279,12 +279,12 @@ public class LegacyProvider4LegacyOperationalTest { }).hasMessageMatching("^policyVersion is marked .*on.*ull but is null$"); LegacyOperationalPolicy deletedLop = - new LegacyProvider().deleteOperationalPolicy(pfDao, originalLop.getPolicyId(), "1"); + new LegacyProvider().deleteOperationalPolicy(pfDao, originalLop.getPolicyId(), "1"); assertEquals(originalLop, deletedLop); assertThatThrownBy(() -> { new LegacyProvider().getOperationalPolicy(pfDao, originalLop.getPolicyId(), null); - }).hasMessage("no policy found for policy: operational.restart:null"); + }).hasMessage("policies for operational.restart:null do not exist"); LegacyOperationalPolicy otherLop = new LegacyOperationalPolicy(); otherLop.setPolicyId("another-policy"); @@ -296,16 +296,16 @@ public class LegacyProvider4LegacyOperationalTest { assertThatThrownBy(() -> { new LegacyProvider().getOperationalPolicy(pfDao, originalLop.getPolicyId(), null); - }).hasMessage("no policy found for policy: operational.restart:null"); + }).hasMessage("policies for operational.restart:null do not exist"); } private void createPolicyTypes() throws CoderException, PfModelException { Object yamlObject = new Yaml() - .load(ResourceUtils.getResourceAsString("policytypes/onap.policies.controlloop.Operational.yaml")); + .load(ResourceUtils.getResourceAsString("policytypes/onap.policies.controlloop.Operational.yaml")); String yamlAsJsonString = new StandardCoder().encode(yamlObject); ToscaServiceTemplate toscaServiceTemplatePolicyType = - standardCoder.decode(yamlAsJsonString, ToscaServiceTemplate.class); + standardCoder.decode(yamlAsJsonString, ToscaServiceTemplate.class); assertNotNull(toscaServiceTemplatePolicyType); new AuthorativeToscaProvider().createPolicyTypes(pfDao, toscaServiceTemplatePolicyType); diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProviderTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProviderTest.java index a258eedea..e216beada 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProviderTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProviderTest.java @@ -24,6 +24,7 @@ package org.onap.policy.models.tosca.simple.provider; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; import java.util.Properties; @@ -182,8 +183,8 @@ public class SimpleToscaProviderTest { deletedServiceTemplate = new SimpleToscaProvider().deleteDataType(pfDao, dataType0v2.getKey()); - assertEquals(dataType0, deletedServiceTemplate.getDataTypes().get(dataType0Key)); - assertEquals("Updated Description", deletedServiceTemplate.getDataTypes().get(dataType0Key).getDescription()); + assertEquals(dataType0v2, deletedServiceTemplate.getDataTypes().get(dataType0v2.getKey())); + assertNull(deletedServiceTemplate.getDataTypes().get(dataType0v2.getKey()).getDescription()); assertThatThrownBy(() -> new SimpleToscaProvider().deleteDataType(pfDao, dataType0Key)) .hasMessage("data type DataType0:0.0.1 is in use, it is referenced in policy type pt0:0.0.2"); @@ -282,6 +283,10 @@ public class SimpleToscaProviderTest { assertThatThrownBy(() -> new SimpleToscaProvider().deletePolicyType(pfDao, policyType0Key)) .hasMessage("no policy types found"); + + JpaToscaServiceTemplate newServiceTemplate = + new SimpleToscaProvider().createPolicyTypes(pfDao, serviceTemplate); + assertEquals(serviceTemplate, newServiceTemplate); } @Test @@ -482,6 +487,8 @@ public class SimpleToscaProviderTest { assertThatThrownBy(() -> new SimpleToscaProvider().deletePolicy(pfDao, policyKey)) .hasMessage("no policies found"); + + new SimpleToscaProvider().createPolicies(pfDao, originalServiceTemplate); } @Test diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaServiceTemplateProviderTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaServiceTemplateProviderTest.java index 791928a0e..ab46d082b 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaServiceTemplateProviderTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaServiceTemplateProviderTest.java @@ -89,10 +89,10 @@ public class SimpleToscaServiceTemplateProviderTest { public void testCreateUpdateGetDeleteDataType() throws PfModelException { JpaToscaServiceTemplate serviceTemplate = new JpaToscaServiceTemplate(); - JpaToscaServiceTemplate overwrittenServiceTemplate = - new SimpleToscaServiceTemplateProvider().write(pfDao, serviceTemplate); + JpaToscaServiceTemplate dbServiceTemplate = + new SimpleToscaServiceTemplateProvider().write(pfDao, serviceTemplate); - assertNull(overwrittenServiceTemplate); + assertEquals(serviceTemplate, dbServiceTemplate); JpaToscaServiceTemplate readServiceTemplate = new SimpleToscaServiceTemplateProvider().read(pfDao); assertEquals(serviceTemplate, readServiceTemplate); @@ -105,8 +105,8 @@ public class SimpleToscaServiceTemplateProviderTest { serviceTemplate.setDataTypes(new JpaToscaDataTypes()); serviceTemplate.getDataTypes().getConceptMap().put(dataType0Key, dataType0); - overwrittenServiceTemplate = new SimpleToscaServiceTemplateProvider().write(pfDao, serviceTemplate); - assertEquals(readServiceTemplate, overwrittenServiceTemplate); + dbServiceTemplate = new SimpleToscaServiceTemplateProvider().write(pfDao, serviceTemplate); + assertEquals(serviceTemplate, dbServiceTemplate); readServiceTemplate = new SimpleToscaServiceTemplateProvider().read(pfDao); assertEquals(serviceTemplate, readServiceTemplate); @@ -117,8 +117,8 @@ public class SimpleToscaServiceTemplateProviderTest { dataType0.setDescription("Updated Description"); - overwrittenServiceTemplate = new SimpleToscaServiceTemplateProvider().write(pfDao, serviceTemplate); - assertEquals(readServiceTemplate, overwrittenServiceTemplate); + dbServiceTemplate = new SimpleToscaServiceTemplateProvider().write(pfDao, serviceTemplate); + assertEquals(serviceTemplate, dbServiceTemplate); readServiceTemplate = new SimpleToscaServiceTemplateProvider().read(pfDao); assertEquals(serviceTemplate, readServiceTemplate); @@ -135,8 +135,8 @@ public class SimpleToscaServiceTemplateProviderTest { serviceTemplate.getPolicyTypes().getConceptMap().put(policyType0Key, policyType0); - overwrittenServiceTemplate = new SimpleToscaServiceTemplateProvider().write(pfDao, serviceTemplate); - assertEquals(readServiceTemplate, overwrittenServiceTemplate); + dbServiceTemplate = new SimpleToscaServiceTemplateProvider().write(pfDao, serviceTemplate); + assertEquals(serviceTemplate, dbServiceTemplate); readServiceTemplate = new SimpleToscaServiceTemplateProvider().read(pfDao); assertEquals(serviceTemplate, readServiceTemplate); |