use of org.iobserve.analysis.deployment.data.PCMDeployedEvent in project iobserve-analysis by research-iobserve.
the class DeploymentVisualizationStageTest method setUp.
/**
* Initialize test data and stub necessary method calls.
*
* @throws MalformedURLException
* if the creation of the URL fails.
*/
@Before
public void setUp() throws MalformedURLException {
final URL changelogURL = new URL("http://" + DeploymentVisualizationStageTest.OUTPUT_HOSTNAME + ":" + DeploymentVisualizationStageTest.OUTPUT_PORT + "/v1/systems/" + DeploymentVisualizationStageTest.SYSTEM_ID + "/changelogs");
/**
* test correspondent
*/
DeploymentVisualizationStageTest.testCorrespondent = CorrespondentFactory.newInstance("test.org.pcm.entity", "testPcmEntityId", "testPcmOperationName", "testPcmOperationId");
DeploymentVisualizationStageTest.optTestCorrespondent = Optional.of(DeploymentVisualizationStageTest.testCorrespondent);
/**
* test resource container
*/
this.testResourceContainer = ResourceenvironmentFactory.eINSTANCE.createResourceContainer();
this.testResourceContainer.setId(DeploymentVisualizationStageTest.TEST_NODE_ID);
this.testResourceContainers.add(this.testResourceContainer);
/**
* test events
*/
final String urlContext = DeploymentVisualizationStageTest.CONTEXT.replaceAll("\\.", "/");
final String url = "http://" + DeploymentVisualizationStageTest.SERVICE + '/' + urlContext;
this.deployedEvent = new PCMDeployedEvent(DeploymentVisualizationStageTest.SERVICE, DeploymentVisualizationStageTest.testCorrespondent, url, (short) 0);
this.deployedEvent.setResourceContainer(this.testResourceContainer);
/**
* input events
*/
this.inputEvents.add(this.deployedEvent);
/**
* test assembly context
*/
final String asmContextName = DeploymentVisualizationStageTest.testCorrespondent.getPcmEntityName() + "_" + DeploymentVisualizationStageTest.SERVICE;
this.testAssemblyContext = CompositionFactory.eINSTANCE.createAssemblyContext();
this.testAssemblyContext.setId(DeploymentVisualizationStageTest.SYSTEM_ID);
this.testAssemblyContext.setEntityName(asmContextName);
this.testAssemblyContexts.add(this.testAssemblyContext);
// stubbing
Mockito.when(this.mockedResourceContainerModelProvider.readOnlyComponentByName(ResourceContainer.class, DeploymentVisualizationStageTest.SERVICE)).thenReturn(this.testResourceContainers);
Mockito.when(this.mockedCorrespondenceModel.getCorrespondent(DeploymentVisualizationStageTest.CONTEXT)).thenReturn(DeploymentVisualizationStageTest.optTestCorrespondent);
Mockito.when(this.mockedAssemblyContextModelProvider.readOnlyComponentByName(AssemblyContext.class, asmContextName)).thenReturn(this.testAssemblyContexts);
this.deploymentVisualizationStage = new DeploymentVisualizationStage(changelogURL, DeploymentVisualizationStageTest.SYSTEM_ID, this.mockedResourceContainerModelProvider, this.mockedAssemblyContextModelProvider);
}
use of org.iobserve.analysis.deployment.data.PCMDeployedEvent in project iobserve-analysis by research-iobserve.
the class DeployPCMMapperTest method testExecuteIDeployed.
/**
* Test method for
* {@link org.iobserve.analysis.deployment.DeployPCMMapper#execute(org.iobserve.common.record.IDeployed)}.
*/
@Test
public void testExecuteIDeployed() {
final DeployPCMMapper mapper = new DeployPCMMapper(DeployPCMMapperTest.mockedCorrespondence);
final List<PCMDeployedEvent> deploymentEvents = new ArrayList<>();
StageTester.test(mapper).and().send(DeployPCMMapperTest.inputEvents).to(mapper.getInputPort()).and().receive(deploymentEvents).from(mapper.getOutputPort()).start();
Assert.assertEquals("Number of events differ.", deploymentEvents.size(), DeployPCMMapperTest.pcmDeployedEvents.size());
Assert.assertEquals("Different events.", deploymentEvents.get(0).getService(), ModelLevelData.PCM_DEPLOYED_EVENT.getService());
}
Aggregations