Search in sources :

Example 6 with ParameterValue

use of bpsim.ParameterValue in project kie-wb-common by kiegroup.

the class BaseEventPropertyReaderTest method testGetSimulationSet.

private void testGetSimulationSet(SimulationAttributeSet expectedResult, ParameterValue distributionType) {
    ElementParameters parameters = mock(ElementParameters.class);
    TimeParameters timeParams = mock(TimeParameters.class);
    when(parameters.getTimeParameters()).thenReturn(timeParams);
    Parameter processingTime = mock(Parameter.class);
    when(timeParams.getProcessingTime()).thenReturn(processingTime);
    EList<ParameterValue> parameterList = mock(EList.class);
    when(processingTime.getParameterValue()).thenReturn(parameterList);
    when(parameterList.get(0)).thenReturn(distributionType);
    when(definitionResolver.resolveSimulationParameters(getCurrentEventMock().getId())).thenReturn(Optional.ofNullable(parameters));
    assertEquals(expectedResult, propertyReader.getSimulationSet());
}
Also used : ParameterValue(bpsim.ParameterValue) ElementParameters(bpsim.ElementParameters) Parameter(bpsim.Parameter) TimeParameters(bpsim.TimeParameters)

Example 7 with ParameterValue

use of bpsim.ParameterValue in project kie-wb-common by kiegroup.

the class BaseEventPropertyReaderTest method testGetSimulationSetNormalDistribution.

@Test
public void testGetSimulationSetNormalDistribution() {
    ParameterValue paramValue = mockNormalDistributionType(MEAN, STANDARD_DEVIATION);
    testGetSimulationSet(new SimulationAttributeSet(0d, 0d, MEAN, "ms", STANDARD_DEVIATION, "normal"), paramValue);
}
Also used : ParameterValue(bpsim.ParameterValue) SimulationAttributeSet(org.kie.workbench.common.stunner.bpmn.definition.property.simulation.SimulationAttributeSet) Test(org.junit.Test)

Example 8 with ParameterValue

use of bpsim.ParameterValue in project kie-wb-common by kiegroup.

the class Bpmn2JsonMarshaller method extractTimeParamsToProperties.

private void extractTimeParamsToProperties(ElementParameters eleType, Map<String, Object> properties) {
    TimeParameters timeParams = eleType.getTimeParameters();
    if (timeParams != null) {
        Parameter processingTime = timeParams.getProcessingTime();
        if (processingTime != null && processingTime.getParameterValue() != null && processingTime.getParameterValue().size() > 0) {
            ParameterValue paramValue = processingTime.getParameterValue().get(0);
            if (paramValue instanceof NormalDistributionType) {
                NormalDistributionType ndt = (NormalDistributionType) paramValue;
                properties.put(MEAN, ndt.getMean());
                properties.put(STANDARDDEVIATION, ndt.getStandardDeviation());
                properties.put(DISTRIBUTIONTYPE, "normal");
            } else if (paramValue instanceof UniformDistributionType) {
                UniformDistributionType udt = (UniformDistributionType) paramValue;
                properties.put(MIN, udt.getMin());
                properties.put(MAX, udt.getMax());
                properties.put(DISTRIBUTIONTYPE, "uniform");
            } else if (paramValue instanceof PoissonDistributionType) {
                PoissonDistributionType pdt = (PoissonDistributionType) paramValue;
                properties.put(MEAN, pdt.getMean());
                properties.put(DISTRIBUTIONTYPE, "poisson");
            }
            if (timeParams.getWaitTime() != null) {
                extractParamTypeToProperties(WAITTIME, timeParams.getWaitTime().getParameterValue(), properties);
            }
        }
    }
}
Also used : UniformDistributionType(bpsim.UniformDistributionType) PoissonDistributionType(bpsim.PoissonDistributionType) ParameterValue(bpsim.ParameterValue) NormalDistributionType(bpsim.NormalDistributionType) Parameter(bpsim.Parameter) TimeParameters(bpsim.TimeParameters)

Example 9 with ParameterValue

use of bpsim.ParameterValue in project kie-wb-common by kiegroup.

the class BaseEventPropertyReaderTest method testGetSimulationSetPoissonDistribution.

@Test
public void testGetSimulationSetPoissonDistribution() {
    ParameterValue paramValue = mockPoissonDistributionType(MEAN);
    testGetSimulationSet(new SimulationAttributeSet(0d, 0d, MEAN, "ms", 0d, "poisson"), paramValue);
}
Also used : ParameterValue(bpsim.ParameterValue) SimulationAttributeSet(org.kie.workbench.common.stunner.bpmn.definition.property.simulation.SimulationAttributeSet) Test(org.junit.Test)

Example 10 with ParameterValue

use of bpsim.ParameterValue in project kie-wb-common by kiegroup.

the class BaseEventPropertyReaderTest method testGetSimulationSetUniformDistribution.

@Test
public void testGetSimulationSetUniformDistribution() {
    ParameterValue paramValue = mockUniformDistributionType(MIN, MAX);
    testGetSimulationSet(new SimulationAttributeSet(MIN, MAX, 0d, "ms", 0d, "uniform"), paramValue);
}
Also used : ParameterValue(bpsim.ParameterValue) SimulationAttributeSet(org.kie.workbench.common.stunner.bpmn.definition.property.simulation.SimulationAttributeSet) Test(org.junit.Test)

Aggregations

ParameterValue (bpsim.ParameterValue)11 Parameter (bpsim.Parameter)6 TimeParameters (bpsim.TimeParameters)6 SimulationAttributeSet (org.kie.workbench.common.stunner.bpmn.definition.property.simulation.SimulationAttributeSet)6 ElementParameters (bpsim.ElementParameters)5 FloatingParameterType (bpsim.FloatingParameterType)5 NormalDistributionType (bpsim.NormalDistributionType)5 PoissonDistributionType (bpsim.PoissonDistributionType)5 UniformDistributionType (bpsim.UniformDistributionType)5 Match (org.kie.workbench.common.stunner.bpmn.backend.converters.Match)4 CostParameters (bpsim.CostParameters)3 ResourceParameters (bpsim.ResourceParameters)3 EList (org.eclipse.emf.common.util.EList)3 Test (org.junit.Test)3 SimulationSet (org.kie.workbench.common.stunner.bpmn.definition.property.simulation.SimulationSet)3 VoidMatch (org.kie.workbench.common.stunner.bpmn.backend.converters.VoidMatch)2 Factories.bpsim (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.Factories.bpsim)2