blob: 36984e646c32f5a8f28767e623ed972b141a7fed [file] [log] [blame]
/********************************************************************************
* Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*
********************************************************************************/
package org.eclipse.mdm.businessobjects.boundary.integrationtest;
import org.eclipse.mdm.api.base.model.ContextType;
import org.eclipse.mdm.api.base.model.ValueType;
import org.eclipse.mdm.api.dflt.model.CatalogAttribute;
import org.eclipse.mdm.api.dflt.model.CatalogComponent;
import org.eclipse.mdm.api.dflt.model.TemplateAttribute;
import org.eclipse.mdm.api.dflt.model.TemplateComponent;
import org.eclipse.mdm.api.dflt.model.TemplateRoot;
import org.eclipse.mdm.businessobjects.utils.ServiceUtils;
import org.junit.AfterClass;
import org.junit.BeforeClass;
/**
* Test class for NestedTemplateAttributeResource for TestSequence
* {@link ContextType}.
*
* @author Alexander Nehmer, science+computing AG Tuebingen (Atos SE)
* @see EntityResourceIntegrationTest
*
*/
public class NestedTemplateAttributeTSQResourceIntegrationTest extends EntityResourceIntegrationTest {
@BeforeClass
public static void prepareTestData() {
getLogger().debug("Preparing NestedTemplateAttributeTSQResourceIntegrationTest");
// prepare test data for creating the CatalogAttribute
CatalogAttributeTSQResourceIntegrationTest.prepareTestData();
CatalogAttributeTSQResourceIntegrationTest.createEntity();
// prepare test data for creating the NestedTemplateComponent
NestedTemplateComponentTSQResourceIntegrationTest.prepareTestData();
NestedTemplateComponentTSQResourceIntegrationTest.createEntity();
setContextClass(NestedTemplateAttributeTSQResourceIntegrationTest.class);
// set up test data
putTestDataValue(TESTDATA_RESOURCE_URI, "/tplroots/testsequence/"
+ getTestDataValue(TemplateRootTSQResourceIntegrationTest.class, TESTDATA_ENTITY_ID) + "/tplcomps/"
+ getTestDataValue(TemplateComponentTSQResourceIntegrationTest.class, TESTDATA_ENTITY_ID) + "/tplcomps/"
+ getTestDataValue(NestedTemplateComponentTSQResourceIntegrationTest.class, TESTDATA_ENTITY_ID)
+ "/tplattrs");
putTestDataValue(TESTDATA_ENTITY_NAME,
getTestDataValue(CatalogAttributeTSQResourceIntegrationTest.class, TESTDATA_ENTITY_NAME));
putTestDataValue(TESTDATA_ENTITY_TYPE, "TemplateAttribute");
CatalogComponent catComp = ENTITY_FACTORY.createCatalogComponent(ContextType.TESTSEQUENCE,
getTestDataValue(CatalogComponentTSQResourceIntegrationTest.class, TESTDATA_ENTITY_NAME));
ServiceUtils.getCore(catComp)
.setID(getTestDataValue(CatalogComponentTSQResourceIntegrationTest.class, TESTDATA_ENTITY_ID));
CatalogAttribute catAttr = ENTITY_FACTORY.createCatalogAttribute(getTestDataValue(TESTDATA_ENTITY_NAME),
ValueType.STRING, catComp);
ServiceUtils.getCore(catAttr)
.setID(getTestDataValue(CatalogAttributeTSQResourceIntegrationTest.class, TESTDATA_ENTITY_ID));
TemplateRoot tplRoot = ENTITY_FACTORY.createTemplateRoot(ContextType.TESTSEQUENCE,
getTestDataValue(CatalogComponentTSQResourceIntegrationTest.class, TESTDATA_ENTITY_NAME));
ServiceUtils.getCore(tplRoot)
.setID(getTestDataValue(CatalogComponentTSQResourceIntegrationTest.class, TESTDATA_ENTITY_ID));
TemplateComponent tplComp = ENTITY_FACTORY.createTemplateComponent(
getTestDataValue(TemplateComponentTSQResourceIntegrationTest.class, TESTDATA_ENTITY_NAME), tplRoot,
catComp);
ServiceUtils.getCore(tplComp)
.setID(getTestDataValue(TemplateComponentTSQResourceIntegrationTest.class, TESTDATA_ENTITY_ID));
TemplateComponent nestedTplComp = ENTITY_FACTORY.createTemplateComponent(
getTestDataValue(NestedTemplateComponentTSQResourceIntegrationTest.class, TESTDATA_ENTITY_NAME),
tplComp, catComp);
ServiceUtils.getCore(tplComp)
.setID(getTestDataValue(NestedTemplateComponentTSQResourceIntegrationTest.class, TESTDATA_ENTITY_ID));
// delete the implicitly created TemplateAttribute on the client side
nestedTplComp.removeTemplateAttribute(getTestDataValue(TESTDATA_ENTITY_NAME));
TemplateAttribute nestedTplAttr = ENTITY_FACTORY.createTemplateAttribute(getTestDataValue(TESTDATA_ENTITY_NAME),
nestedTplComp);
putTestDataValue(TESTDATA_CREATE_JSON_BODY, toJson(nestedTplAttr));
// delete the implicitly created NestedTemplateAttribute
NestedTemplateAttributeTSQResourceIntegrationTest.findFirst();
NestedTemplateAttributeTSQResourceIntegrationTest.deleteEntity();
}
@AfterClass
public static void tearDownAfterClass() {
setContextClass(NestedTemplateComponentTSQResourceIntegrationTest.class);
NestedTemplateComponentTSQResourceIntegrationTest.deleteEntity();
setContextClass(TemplateComponentTSQResourceIntegrationTest.class);
TemplateComponentTSQResourceIntegrationTest.deleteEntity();
setContextClass(TemplateRootTSQResourceIntegrationTest.class);
TemplateRootTSQResourceIntegrationTest.deleteEntity();
setContextClass(CatalogAttributeTSQResourceIntegrationTest.class);
CatalogAttributeTSQResourceIntegrationTest.deleteEntity();
setContextClass(CatalogComponentTSQResourceIntegrationTest.class);
CatalogComponentTSQResourceIntegrationTest.deleteEntity();
}
}