diff --git a/edu.kit.ipd.descartes.adaptation.test/src/edu/kit/ipd/descartes/adaptation/util/DmmModelActionHelperTest.java b/edu.kit.ipd.descartes.adaptation.test/src/edu/kit/ipd/descartes/adaptation/util/DmmModelActionHelperTest.java new file mode 100644 index 0000000000000000000000000000000000000000..d8fc8c963a1077ad151d158aaf3f83dc4f7f5c2f --- /dev/null +++ b/edu.kit.ipd.descartes.adaptation.test/src/edu/kit/ipd/descartes/adaptation/util/DmmModelActionHelperTest.java @@ -0,0 +1,66 @@ +package edu.kit.ipd.descartes.adaptation.util; + +import static org.junit.Assert.assertEquals; + +import org.eclipse.emf.ecore.EObject; +import org.junit.Before; +import org.junit.Test; + +import edu.kit.ipd.descartes.core.AdaptableEntity; +import edu.kit.ipd.descartes.mm.containerrepository.ContainerTemplate; +import edu.kit.ipd.descartes.mm.containerrepository.ContainerrepositoryFactory; +import edu.kit.ipd.descartes.mm.containerrepository.ContainerrepositoryPackage; +import edu.kit.ipd.descartes.mm.resourceconfiguration.ActiveResourceSpecification; +import edu.kit.ipd.descartes.mm.resourceconfiguration.NumberOfParallelProcessingUnits; +import edu.kit.ipd.descartes.mm.resourceconfiguration.PassiveResourceCapacity; +import edu.kit.ipd.descartes.mm.resourceconfiguration.PassiveResourceSpecification; +import edu.kit.ipd.descartes.mm.resourceconfiguration.ProcessingResourceSpecification; +import edu.kit.ipd.descartes.mm.resourceconfiguration.ResourceconfigurationFactory; +import edu.kit.ipd.descartes.mm.resourcelandscape.ComputingInfrastructure; +import edu.kit.ipd.descartes.mm.resourcelandscape.ResourcelandscapeFactory; +import edu.kit.ipd.descartes.mm.resourcelandscape.ResourcelandscapePackage; +import edu.kit.ipd.descartes.mm.resourcelandscape.RuntimeEnvironment; + +public class DmmModelActionHelperTest { + + AdaptableEntity aEntity = null; + AdaptableEntity aEntity2 = null; + RuntimeEnvironment vm = ResourcelandscapeFactory.eINSTANCE.createRuntimeEnvironment(); + ComputingInfrastructure ci = ResourcelandscapeFactory.eINSTANCE.createComputingInfrastructure(); + ContainerTemplate template = ContainerrepositoryFactory.eINSTANCE.createContainerTemplate(); + ActiveResourceSpecification aSpec = ResourceconfigurationFactory.eINSTANCE.createActiveResourceSpecification();; + PassiveResourceSpecification pSpec = ResourceconfigurationFactory.eINSTANCE.createPassiveResourceSpecification();; + + @Before + public void setUp() throws Exception { + NumberOfParallelProcessingUnits parProcUnits = ResourceconfigurationFactory.eINSTANCE.createNumberOfParallelProcessingUnits(); + ProcessingResourceSpecification cpu = ResourceconfigurationFactory.eINSTANCE.createProcessingResourceSpecification(); + cpu.setNrOfParProcUnits(parProcUnits); + PassiveResourceCapacity passiveCapacity = ResourceconfigurationFactory.eINSTANCE.createPassiveResourceCapacity(); + + pSpec.setCapacity(passiveCapacity); + aSpec.getProcessingResourceSpecifications().add(cpu); + + vm.getConfigSpec().add(aSpec); + aEntity = parProcUnits; + + template.getTemplateConfig().add(pSpec); + aEntity2 = passiveCapacity; + } + + @Test + public void testFindParentConfiguredInstance() { + EObject foundClass = null; + + foundClass = DmmModelActionHelper.findParentConfiguredInstance(aEntity); + assertEquals(ResourcelandscapePackage.RUNTIME_ENVIRONMENT, foundClass.eClass().getClassifierID()); + + ci.getConfigSpec().add(aSpec); + foundClass = DmmModelActionHelper.findParentConfiguredInstance(aEntity); + assertEquals(ResourcelandscapePackage.COMPUTING_INFRASTRUCTURE, foundClass.eClass().getClassifierID()); + + foundClass = DmmModelActionHelper.findParentConfiguredInstance(aEntity2); + assertEquals(ContainerrepositoryPackage.CONTAINER_TEMPLATE, foundClass.eClass().getClassifierID()); + } + +}