Search in sources :

Example 16 with Allocation

use of org.palladiosimulator.pcm.allocation.Allocation in project iobserve-analysis by research-iobserve.

the class AllocationModelProviderTest method createThenReadReferencing.

@Override
@Test
public void createThenReadReferencing() throws DBException {
    final Neo4JModelResource<Allocation> resource = ModelProviderTestUtils.prepareResource(AllocationModelProviderTest.CREATE_THEN_READ_REFERENCING, this.prefix, this.ePackage);
    resource.storeModelPartition(this.testModel);
    final AssemblyContext context = SystemDataFactory.findAssemblyContext(this.system, SystemDataFactory.PAYMENT_ASSEMBLY_CONTEXT);
    final List<EObject> readReferencingComponents = resource.collectReferencingObjectsByTypeAndProperty(AssemblyContext.class, CompositionPackage.Literals.ASSEMBLY_CONTEXT, ModelGraphFactory.getIdentification(context));
    // Only the payment server allocation context is referencing the payment assembly context
    Assert.assertTrue(readReferencingComponents.size() == 1);
    Assert.assertTrue(this.equalityHelper.comparePartition(AllocationDataFactory.findAllocationContext(this.testModel, AllocationDataFactory.PAYMENT_ALLOCATION_CONTEXT), readReferencingComponents.get(0), this.testModel.eClass()));
    resource.getGraphDatabaseService().shutdown();
}
Also used : Allocation(org.palladiosimulator.pcm.allocation.Allocation) EObject(org.eclipse.emf.ecore.EObject) AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext) Test(org.junit.Test)

Example 17 with Allocation

use of org.palladiosimulator.pcm.allocation.Allocation in project iobserve-analysis by research-iobserve.

the class AllocationModelProviderTest method createThenUpdateThenReadUpdated.

@Override
@Test
public void createThenUpdateThenReadUpdated() throws NodeLookupException, DBException {
    final Neo4JModelResource<Allocation> resource = ModelProviderTestUtils.prepareResource(AllocationModelProviderTest.CREATE_THEN_UPDATE_THEN_READ_UPDATED, this.prefix, this.ePackage);
    final AllocationContext businessOrderServerAllocationContext = AllocationDataFactory.findAllocationContext(this.testModel, AllocationDataFactory.BUSINESS_ORDER_ALLOCATION_CONTEXT);
    final AllocationContext privateOrderServerAllocationContext = AllocationDataFactory.findAllocationContext(this.testModel, AllocationDataFactory.PRIVATE_ORDER_ALLOCATION_CONTEXT);
    resource.storeModelPartition(this.testModel);
    // Update the model by allocating new separate servers for business and private orders
    final ResourceContainer businessOrderServer = ResourceEnvironmentDataFactory.cloneContainer(this.resourceEnvironment, ResourceEnvironmentDataFactory.BUSINESS_ORDER_CONTAINER, "additionalBusinessOrderServer");
    final ResourceContainer privateOrderServer = ResourceEnvironmentDataFactory.cloneContainer(this.resourceEnvironment, ResourceEnvironmentDataFactory.PRIVATE_ORDER_CONTAINER, "additionalPrivateOrderServer");
    this.resourceEnvironment.getResourceContainer_ResourceEnvironment().add(businessOrderServer);
    this.resourceEnvironment.getResourceContainer_ResourceEnvironment().add(privateOrderServer);
    businessOrderServerAllocationContext.setResourceContainer_AllocationContext(businessOrderServer);
    privateOrderServerAllocationContext.setResourceContainer_AllocationContext(privateOrderServer);
    resource.updatePartition(this.testModel);
    final Allocation readModel = resource.getModelRootNode(Allocation.class, AllocationPackage.Literals.ALLOCATION);
    Assert.assertTrue(this.equalityHelper.comparePartition(this.testModel, readModel, readModel.eClass()));
    resource.getGraphDatabaseService().shutdown();
}
Also used : AllocationContext(org.palladiosimulator.pcm.allocation.AllocationContext) Allocation(org.palladiosimulator.pcm.allocation.Allocation) ResourceContainer(org.palladiosimulator.pcm.resourceenvironment.ResourceContainer) Test(org.junit.Test)

Example 18 with Allocation

use of org.palladiosimulator.pcm.allocation.Allocation in project iobserve-analysis by research-iobserve.

the class PCMNeo4JTest method testUpdate.

/**
 * Test whether updates work as suggested.
 *
 * @throws NodeLookupException
 *             on node lookup errors
 * @throws DBException
 *             on db errors
 */
@Test
public void testUpdate() throws NodeLookupException, DBException {
    /**
     * store model in database.
     */
    this.repositoryResource.storeModelPartition(this.repository);
    this.resourceEnvironmentResource.storeModelPartition(this.resourceEnvironment);
    this.systemResource.storeModelPartition(this.system);
    this.allocationResource.storeModelPartition(this.allocation);
    final AssemblyContext assemblyContext = SystemDataFactory.findAssemblyContext(this.system, SystemDataFactory.QUERY_ASSEMBLY_CONTEXT);
    final ResourceContainer container = ResourceEnvironmentDataFactory.findContainer(this.resourceEnvironment, ResourceEnvironmentDataFactory.QUERY_CONTAINER_3);
    final Allocation allocationModel = this.allocationResource.getModelRootNode(Allocation.class, AllocationPackage.Literals.ALLOCATION);
    final AllocationContext newAllocationContext = AllocationFactory.eINSTANCE.createAllocationContext();
    newAllocationContext.setEntityName(AllocationDataFactory.QUERY_ALLOCATION_CONTEXT_3);
    newAllocationContext.setAssemblyContext_AllocationContext(assemblyContext);
    newAllocationContext.setResourceContainer_AllocationContext(container);
    allocationModel.getAllocationContexts_Allocation().add(newAllocationContext);
    this.allocationResource.updatePartition(allocationModel);
    for (final AllocationContext context : this.allocationResource.collectAllObjectsByType(AllocationContext.class, AllocationPackage.Literals.ALLOCATION_CONTEXT)) {
    // NOCS
    // TODO
    }
}
Also used : AllocationContext(org.palladiosimulator.pcm.allocation.AllocationContext) Allocation(org.palladiosimulator.pcm.allocation.Allocation) AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext) ResourceContainer(org.palladiosimulator.pcm.resourceenvironment.ResourceContainer) Test(org.junit.Test)

Example 19 with Allocation

use of org.palladiosimulator.pcm.allocation.Allocation in project Palladio-Editors-Sirius by PalladioSimulator.

the class AllocationCreationWizard method finish.

@Override
protected void finish() {
    Allocation allocation = (Allocation) modelObject;
    Session session = SessionManager.INSTANCE.getSession(modelObject);
    TransactionalEditingDomain domain = session.getTransactionalEditingDomain();
    String fileString = modelURI.toPlatformString(true);
    IPath path = new Path(fileString);
    IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
    List<IFile> list = new ArrayList<IFile>();
    list.add(file);
    AbstractTransactionalCommand command = new AbstractTransactionalCommand(domain, "Save Allocation model.", list) {

        @Override
        protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
            allocation.setTargetResourceEnvironment_Allocation(resourceEnvironmentSelectorpage.getSelectedResourceEnvironment(session));
            allocation.setSystem_Allocation(systemSelectorPage.getSelectedSystem(session));
            return CommandResult.newOKCommandResult();
        }
    };
    try {
        OperationHistoryFactory.getOperationHistory().execute(command, new NullProgressMonitor(), null);
    } catch (ExecutionException e) {
        System.out.println("Unable to save allocation model.");
        e.printStackTrace();
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IAdaptable(org.eclipse.core.runtime.IAdaptable) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) ArrayList(java.util.ArrayList) AbstractTransactionalCommand(org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) TransactionalEditingDomain(org.eclipse.emf.transaction.TransactionalEditingDomain) Allocation(org.palladiosimulator.pcm.allocation.Allocation) ExecutionException(org.eclipse.core.commands.ExecutionException) Session(org.eclipse.sirius.business.api.session.Session)

Example 20 with Allocation

use of org.palladiosimulator.pcm.allocation.Allocation in project iobserve-analysis by research-iobserve.

the class DeploymentModelUpdaterTest method testExecutePCMDeployedEvent.

/**
 * Test method for
 * {@link org.iobserve.analysis.deployment.DeploymentModelUpdater#execute(org.iobserve.analysis.deployment.data.PCMDeployedEvent)}.
 *
 * @throws DBException
 */
@Test
public void testExecutePCMDeployedEvent() throws DBException {
    java.lang.System.err.println("AAAAAAAAAAAAAAAAAAAAAAa");
    this.initializationDatabase();
    java.lang.System.err.println("q alloc");
    final Allocation initDbAllocation = this.allocationResource.getModelRootNode(Allocation.class, AllocationPackage.Literals.ALLOCATION);
    java.lang.System.err.println("deployer filter");
    final DeploymentModelUpdater deploymentModelUpdater = new DeploymentModelUpdater(this.correspondenceResource, this.allocationResource);
    /**
     * input deployment event
     */
    final AssemblyContext assemblyContext = SystemDataFactory.findAssemblyContext(this.system, SystemDataFactory.QUERY_ASSEMBLY_CONTEXT);
    final PCMDeployedEvent deploymentEvent = ModelLevelDataFactory.createPCMDeployedEvent(ISOCountryCode.EVIL_EMPIRE, assemblyContext);
    deploymentEvent.setResourceContainer(ResourceEnvironmentDataFactory.findContainer(this.resourceEnvironment, ResourceEnvironmentDataFactory.QUERY_CONTAINER_3));
    final List<PCMDeployedEvent> inputEvents = new ArrayList<>();
    inputEvents.add(deploymentEvent);
    StageTester.test(deploymentModelUpdater).and().send(inputEvents).to(deploymentModelUpdater.getInputPort()).start();
    Assert.assertThat(deploymentModelUpdater.getDeployedNotifyOutputPort(), StageTester.produces(deploymentEvent));
    // TODO check is DB contains a deployment
    final Allocation dbAllocation = this.allocationResource.getModelRootNode(Allocation.class, AllocationPackage.Literals.ALLOCATION);
    for (final AllocationContext context : dbAllocation.getAllocationContexts_Allocation()) {
        Assert.assertNotEquals("No assembly context for " + context.getEntityName(), context.getAssemblyContext_AllocationContext(), null);
    }
}
Also used : AllocationContext(org.palladiosimulator.pcm.allocation.AllocationContext) DeploymentModelUpdater(org.iobserve.analysis.deployment.DeploymentModelUpdater) Allocation(org.palladiosimulator.pcm.allocation.Allocation) PCMDeployedEvent(org.iobserve.analysis.deployment.data.PCMDeployedEvent) ArrayList(java.util.ArrayList) AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext) Test(org.junit.Test)

Aggregations

Allocation (org.palladiosimulator.pcm.allocation.Allocation)37 Test (org.junit.Test)16 ResourceEnvironment (org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment)10 System (org.palladiosimulator.pcm.system.System)10 AllocationContext (org.palladiosimulator.pcm.allocation.AllocationContext)9 AssemblyContext (org.palladiosimulator.pcm.core.composition.AssemblyContext)7 ResourceContainer (org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)7 File (java.io.File)4 IOException (java.io.IOException)4 PCMModelHandler (org.iobserve.model.PCMModelHandler)4 Repository (org.palladiosimulator.pcm.repository.Repository)4 CorrespondenceModel (org.iobserve.model.correspondence.CorrespondenceModel)3 DBException (org.iobserve.model.persistence.DBException)3 UsageModel (org.palladiosimulator.pcm.usagemodel.UsageModel)3 ArrayList (java.util.ArrayList)2 URI (org.eclipse.emf.common.util.URI)2 EObject (org.eclipse.emf.ecore.EObject)2 ModelImporter (org.iobserve.model.ModelImporter)2 Neo4JModelResource (org.iobserve.model.persistence.neo4j.Neo4JModelResource)2 DataProtectionModel (org.iobserve.model.privacy.DataProtectionModel)2