Search in sources :

Example 6 with PCMDeployedEvent

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);
}
Also used : PCMDeployedEvent(org.iobserve.analysis.deployment.data.PCMDeployedEvent) URL(java.net.URL) Before(org.junit.Before)

Example 7 with PCMDeployedEvent

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());
}
Also used : PCMDeployedEvent(org.iobserve.analysis.deployment.data.PCMDeployedEvent) ArrayList(java.util.ArrayList) DeployPCMMapper(org.iobserve.analysis.deployment.DeployPCMMapper) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

PCMDeployedEvent (org.iobserve.analysis.deployment.data.PCMDeployedEvent)7 ArrayList (java.util.ArrayList)2 Correspondent (org.iobserve.model.correspondence.Correspondent)2 Test (org.junit.Test)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 URL (java.net.URL)1 DeployPCMMapper (org.iobserve.analysis.deployment.DeployPCMMapper)1 PCMUndeployedEvent (org.iobserve.analysis.deployment.data.PCMUndeployedEvent)1 Privacy_EJBDeployedEvent (org.iobserve.common.record.Privacy_EJBDeployedEvent)1 Privacy_ServletDeployedEvent (org.iobserve.common.record.Privacy_ServletDeployedEvent)1 Warnings (org.iobserve.stages.data.Warnings)1 Before (org.junit.Before)1 ResourceContainer (org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)1