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();
}
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();
}
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
}
}
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();
}
}
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);
}
}
Aggregations