/******************************************************************************** | |
* 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 TemplateComponentResource for TestEquipment | |
* {@link ContextType}. | |
* | |
* @author Philipp Schweinbenz, science+computing AG Tuebingen (Atos SE) | |
* @see EntityResourceIntegrationTest | |
* | |
*/ | |
public class TemplateSensorAttributeResourceIntegrationTest extends EntityResourceIntegrationTest { | |
@BeforeClass | |
public static void prepareTestData() { | |
getLogger().debug("Preparing TemplateSensorAttributeResourceIntegrationTest"); | |
// prepare test data for creating the CatalogSensorAttribute | |
CatalogSensorAttributeResourceIntegrationTest.prepareTestData(); | |
CatalogSensorAttributeResourceIntegrationTest.createEntity(); | |
// prepare test data for creating the TemplateSensor | |
TemplateSensorResourceIntegrationTest.prepareTestData(); | |
TemplateSensorResourceIntegrationTest.createEntity(); | |
// set up test data | |
setContextClass(TemplateSensorAttributeResourceIntegrationTest.class); | |
// skip the creation test as TemplateSensorAttributes are implicitly created | |
// with the TemplateSensor | |
skipTest(TestType.CREATE); | |
// skip the deletion test as TemplateSensorAttributes can't be deleted | |
skipTest(TestType.DELETE); | |
putTestDataValue(TESTDATA_RESOURCE_URI, "/tplroots/testequipment/" | |
+ getTestDataValue(TemplateRootTEQResourceIntegrationTest.class, TESTDATA_ENTITY_ID) + "/tplcomps/" | |
+ getTestDataValue(TemplateComponentTEQResourceIntegrationTest.class, TESTDATA_ENTITY_ID) | |
+ "/tplsensors/" + getTestDataValue(TemplateSensorResourceIntegrationTest.class, TESTDATA_ENTITY_ID) | |
+ "/tplsensorattrs"); | |
putTestDataValue(TESTDATA_ENTITY_NAME, | |
getTestDataValue(CatalogSensorAttributeResourceIntegrationTest.class, TESTDATA_ENTITY_NAME)); | |
putTestDataValue(TESTDATA_ENTITY_TYPE, "TemplateAttribute"); | |
CatalogComponent catComp = ENTITY_FACTORY.createCatalogComponent(ContextType.TESTSEQUENCE, | |
getTestDataValue(CatalogComponentTEQResourceIntegrationTest.class, TESTDATA_ENTITY_NAME)); | |
ServiceUtils.getCore(catComp) | |
.setID(getTestDataValue(CatalogComponentTEQResourceIntegrationTest.class, TESTDATA_ENTITY_ID)); | |
CatalogAttribute catAttr = ENTITY_FACTORY.createCatalogAttribute(getTestDataValue(TESTDATA_ENTITY_NAME), | |
ValueType.STRING, catComp); | |
ServiceUtils.getCore(catAttr) | |
.setID(getTestDataValue(CatalogComponentTEQResourceIntegrationTest.class, TESTDATA_ENTITY_ID)); | |
TemplateRoot tplRoot = ENTITY_FACTORY.createTemplateRoot(ContextType.TESTSEQUENCE, | |
getTestDataValue(TemplateRootTEQResourceIntegrationTest.class, TESTDATA_ENTITY_NAME)); | |
ServiceUtils.getCore(tplRoot) | |
.setID(getTestDataValue(TemplateRootTEQResourceIntegrationTest.class, TESTDATA_ENTITY_ID)); | |
TemplateComponent tplComp = ENTITY_FACTORY.createTemplateComponent(getTestDataValue(TESTDATA_ENTITY_NAME), | |
tplRoot, catComp); | |
ServiceUtils.getCore(tplComp) | |
.setID(getTestDataValue(TemplateComponentTEQResourceIntegrationTest.class, TESTDATA_ENTITY_ID)); | |
// delete the implicitly created TemplateAttribute on the client side | |
tplComp.removeTemplateAttribute(getTestDataValue(TESTDATA_ENTITY_NAME)); | |
TemplateAttribute tplAttr = ENTITY_FACTORY.createTemplateAttribute(getTestDataValue(TESTDATA_ENTITY_NAME), | |
tplComp); | |
ServiceUtils.getCore(tplAttr).getMutableStore().remove(CatalogAttribute.class); | |
putTestDataValue(TESTDATA_CREATE_JSON_BODY, toJson(tplAttr)); | |
// get first TemplateSensorAttribute | |
TemplateSensorAttributeResourceIntegrationTest.findFirst(); | |
} | |
@AfterClass | |
public static void tearDownAfterClass() { | |
setContextClass(TemplateSensorResourceIntegrationTest.class); | |
TemplateSensorResourceIntegrationTest.deleteEntity(); | |
setContextClass(TemplateComponentTEQResourceIntegrationTest.class); | |
TemplateComponentTEQResourceIntegrationTest.deleteEntity(); | |
setContextClass(TemplateRootTEQResourceIntegrationTest.class); | |
TemplateRootTEQResourceIntegrationTest.deleteEntity(); | |
setContextClass(CatalogSensorAttributeResourceIntegrationTest.class); | |
CatalogSensorAttributeResourceIntegrationTest.deleteEntity(); | |
setContextClass(CatalogSensorResourceIntegrationTest.class); | |
CatalogSensorResourceIntegrationTest.deleteEntity(); | |
setContextClass(CatalogComponentTEQResourceIntegrationTest.class); | |
CatalogComponentTEQResourceIntegrationTest.deleteEntity(); | |
setContextClass(QuantityResourceIntegrationTest.class); | |
QuantityResourceIntegrationTest.deleteEntity(); | |
} | |
} |