use of org.iobserve.analysis.deployment.DeploymentModelUpdater in project iobserve-analysis by research-iobserve.
the class DeploymentResourceContainerTest method stubMocksResourceContainer.
/**
* Define the test situation in which the needed {@link ResourceContainer} exists in the given
* {@link ResourceEnvironment} model.
*/
@Before
public void stubMocksResourceContainer() {
/**
* mock for ModelBuilder
*/
// use PowerMockito for calling static methods of these final classes
PowerMockito.mockStatic(ResourceEnvironmentModelFactory.class);
PowerMockito.mockStatic(AllocationModelFactory.class);
PowerMockito.mockStatic(SystemModelFactory.class);
this.deploymentModelUpdater = new DeploymentModelUpdater(DeploymentResourceContainerTest.mockedAllocationModelGraphProvider, DeploymentResourceContainerTest.mockedSystemModelGraphProvider);
/**
* get models
*/
Mockito.when(DeploymentResourceContainerTest.mockedCorrespondence.getCorrespondent(ImplementationLevelDataFactory.CONTEXT)).thenReturn(Optional.of(CorrespondenceModelDataFactory.CORRESPONDENT));
Mockito.when(DeploymentResourceContainerTest.mockedAllocationModelGraphProvider.readOnlyRootComponent(Allocation.class)).thenReturn(AllocationDataFactory.ALLOCATION);
Mockito.when(DeploymentResourceContainerTest.mockedResourceEnvironmentModelGraphProvider.readOnlyRootComponent(ResourceEnvironment.class)).thenReturn(ResourceEnvironmentDataFactory.RESOURCE_ENVIRONMENT);
Mockito.when(DeploymentResourceContainerTest.mockedSystemModelGraphProvider.readOnlyRootComponent(org.palladiosimulator.pcm.system.System.class)).thenReturn(SystemDataFactory.SYSTEM);
/**
* get part of models
*/
Mockito.when(SystemModelFactory.getAssemblyContextByName(SystemDataFactory.SYSTEM, AssemblyContextDataFactory.ASSEMBLY_CONTEXT_NAME)).thenReturn(Optional.of(AssemblyContextDataFactory.ASSEMBLY_CONTEXT));
Mockito.when(ResourceEnvironmentModelFactory.getResourceContainerByName(ResourceEnvironmentDataFactory.RESOURCE_ENVIRONMENT, ImplementationLevelDataFactory.SERVICE)).thenReturn(Optional.of(ResourceEnvironmentDataFactory.RESOURCE_CONTAINER));
/**
* interaction with graphs
*/
Mockito.when(SystemModelFactory.createAssemblyContextsIfAbsent(SystemDataFactory.SYSTEM, ImplementationLevelDataFactory.SERVICE)).thenReturn(AssemblyContextDataFactory.ASSEMBLY_CONTEXT);
Mockito.doNothing().when(DeploymentResourceContainerTest.mockedSystemModelGraphProvider).updateComponent(org.palladiosimulator.pcm.system.System.class, SystemDataFactory.SYSTEM);
PowerMockito.doNothing().when(AllocationModelFactory.class);
AllocationModelFactory.addAllocationContext(AllocationDataFactory.ALLOCATION, ResourceEnvironmentDataFactory.RESOURCE_CONTAINER, AssemblyContextDataFactory.ASSEMBLY_CONTEXT);
Mockito.doNothing().when(DeploymentResourceContainerTest.mockedAllocationModelGraphProvider).updateComponent(Allocation.class, AllocationDataFactory.ALLOCATION);
}
use of org.iobserve.analysis.deployment.DeploymentModelUpdater 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);
}
}
use of org.iobserve.analysis.deployment.DeploymentModelUpdater in project iobserve-analysis by research-iobserve.
the class DeploymentResourceContainerTest method stubMocksResourceContainer.
/**
* Define the test situation in which the needed {@link ResourceContainer} exists in the given
* {@link ResourceEnvironment} model.
*
* @throws NodeLookupException
* @throws DBException
*/
@Before
public void stubMocksResourceContainer() throws NodeLookupException, DBException {
/**
* mock for ModelBuilder
*/
// use PowerMockito for calling static methods of these final classes
PowerMockito.mockStatic(ResourceEnvironmentModelFactory.class);
PowerMockito.mockStatic(SystemModelFactory.class);
this.deploymentModelUpdater = new DeploymentModelUpdater(DeploymentResourceContainerTest.mockedCorrespondence, DeploymentResourceContainerTest.mockedAllocationModelGraphProvider);
/**
* get models
*/
// this makes no sense anymore
// Mockito.when(DeploymentResourceContainerTest.mockedCorrespondence
// .getCorrespondent(ImplementationLevelDataFactory.CONTEXT))
// .thenReturn(Optional.of(CorrespondenceModelDataFactory.CORRESPONDENT));
Mockito.when(DeploymentResourceContainerTest.mockedAllocationModelGraphProvider.getModelRootNode(Allocation.class, AllocationPackage.Literals.ALLOCATION)).thenReturn(DeploymentResourceContainerTest.allocation);
Mockito.when(DeploymentResourceContainerTest.mockedResourceEnvironmentModelGraphProvider.getModelRootNode(ResourceEnvironment.class, ResourceenvironmentPackage.Literals.RESOURCE_ENVIRONMENT)).thenReturn(DeploymentResourceContainerTest.resourceEnvironment);
// TODO fix this
// Mockito.when(DeploymentResourceContainerTest.allocationContextModelGraphProvider
// .readOnlyRootComponent(AllocationContext.class)).thenReturn(AllocationDataFactory.ALLOCATION);
/**
* get part of models
*/
Mockito.when(SystemModelFactory.getAssemblyContextByName(DeploymentResourceContainerTest.system, DeploymentResourceContainerTest.system.getAssemblyContexts__ComposedStructure().get(0).getEntityName())).thenReturn(Optional.of(DeploymentResourceContainerTest.system.getAssemblyContexts__ComposedStructure().get(0)));
Mockito.when(ResourceEnvironmentModelFactory.getResourceContainerByName(DeploymentResourceContainerTest.resourceEnvironment, ImplementationLevelDataFactory.SERVICE)).thenReturn(Optional.of(DeploymentResourceContainerTest.resourceEnvironment.getResourceContainer_ResourceEnvironment().get(0)));
/**
* interaction with graphs
*/
Mockito.when(SystemModelFactory.createAssemblyContextsIfAbsent(DeploymentResourceContainerTest.system, ImplementationLevelDataFactory.SERVICE)).thenReturn(DeploymentResourceContainerTest.system.getAssemblyContexts__ComposedStructure().get(0));
this.addAllocationContext(DeploymentResourceContainerTest.allocation, DeploymentResourceContainerTest.resourceEnvironment.getResourceContainer_ResourceEnvironment().get(0), DeploymentResourceContainerTest.system.getAssemblyContexts__ComposedStructure().get(0));
Mockito.doNothing().when(DeploymentResourceContainerTest.mockedAllocationModelGraphProvider).updatePartition(DeploymentResourceContainerTest.allocation);
}
Aggregations