public FactMapping cloneFactMapping() { return new FactMapping(this); }
public FactMapping cloneFactMapping() { return new FactMapping(this); }
public FactMapping addFactMapping(int index, String factAlias, FactIdentifier factIdentifier, ExpressionIdentifier expressionIdentifier) { if (getFactMapping(factIdentifier, expressionIdentifier).isPresent()) { throw new IllegalArgumentException( new StringBuilder().append("An expression with name '").append(expressionIdentifier.getName()) .append("' already exists for the fact '").append(factIdentifier.getName()).append("'").toString()); } if (index > factMappings.size()) { throw new IllegalArgumentException( new StringBuilder().append("Impossible to add an element at position ").append(index) .append(" because there are only ").append(factMappings.size()).append(" elements").toString()); } FactMapping factMapping = new FactMapping(factAlias, factIdentifier, expressionIdentifier); factMappings.add(index, factMapping); return factMapping; }
public FactMapping addFactMapping(int index, String factAlias, FactIdentifier factIdentifier, ExpressionIdentifier expressionIdentifier) { if (getFactMapping(factIdentifier, expressionIdentifier).isPresent()) { throw new IllegalArgumentException( new StringBuilder().append("An expression with name '").append(expressionIdentifier.getName()) .append("' already exists for the fact '").append(factIdentifier.getName()).append("'").toString()); } if (index > factMappings.size()) { throw new IllegalArgumentException( new StringBuilder().append("Impossible to add an element at position ").append(index) .append(" because there are only ").append(factMappings.size()).append(" elements").toString()); } FactMapping factMapping = new FactMapping(factAlias, factIdentifier, expressionIdentifier); factMappings.add(index, factMapping); return factMapping; }
@Test public void getExpressionElementsWithoutClass() { FactMapping original = new FactMapping("FACT_ALIAS", new FactIdentifier("FI_TEST", "com.test.Foo"), new ExpressionIdentifier("EI_TEST", FactMappingType.GIVEN)); assertThatThrownBy(original::getExpressionElementsWithoutClass) .isInstanceOf(IllegalStateException.class) .hasMessage("ExpressionElements malformed"); assertEquals(0, original.getExpressionElements().size()); original.addExpressionElement("STEP", String.class.getCanonicalName()); assertEquals(0, original.getExpressionElementsWithoutClass().size()); assertEquals(1, original.getExpressionElements().size()); } }
@Test public void getExpressionElementsWithoutClass() { FactMapping original = new FactMapping("FACT_ALIAS", new FactIdentifier("FI_TEST", "com.test.Foo"), new ExpressionIdentifier("EI_TEST", FactMappingType.GIVEN)); assertThatThrownBy(original::getExpressionElementsWithoutClass) .isInstanceOf(IllegalStateException.class) .hasMessage("ExpressionElements malformed"); assertEquals(0, original.getExpressionElements().size()); original.addExpressionElement("STEP", String.class.getCanonicalName()); assertEquals(0, original.getExpressionElementsWithoutClass().size()); assertEquals(1, original.getExpressionElements().size()); } }
@Before public void setup() { when(scenarioGridColumnMock.getPropertyHeaderMetaData()).thenReturn(propertyHeaderMetadataMock); factIdentifierGiven = new FactIdentifier("GIVEN", "GIVEN"); factIdentifierInteger = new FactIdentifier("Integer", "java.lang.Integer"); factMappingDescription = new FactMapping(EXPRESSION_ALIAS_DESCRIPTION, FactIdentifier.DESCRIPTION, ExpressionIdentifier.DESCRIPTION); factMappingGiven = new FactMapping(EXPRESSION_ALIAS_GIVEN, factIdentifierGiven, new ExpressionIdentifier("GIVEN", FactMappingType.GIVEN)); factMappingInteger = new FactMapping(EXPRESSION_ALIAS_INTEGER, factIdentifierInteger, new ExpressionIdentifier("GIVEN", FactMappingType.GIVEN)); factMappingIndex = new FactMapping(EXPRESSION_ALIAS_INDEX, FactIdentifier.INDEX, ExpressionIdentifier.INDEX); simulation = getSimulation(); scenarioGrid = spy(new ScenarioGrid(scenarioGridModelMock, scenarioGridLayerMock, scenarioGridRendererMock, scenarioGridPanelMock) { @Override protected void appendRow(int rowIndex, Scenario scenario) { // do nothing } @Override protected ScenarioHeaderTextBoxSingletonDOMElementFactory getScenarioHeaderTextBoxSingletonDOMElementFactory() { return scenarioHeaderTextBoxSingletonDOMElementFactoryMock; } @Override protected ScenarioSimulationBuilders.HeaderBuilder getHeaderBuilderLocal(String instanceTitle, String propertyTitle, String columnId, String columnGroup, FactMappingType factMappingType, ScenarioHeaderTextBoxSingletonDOMElementFactory factoryHeader) { return headerBuilderMock; } @Override protected ScenarioGridColumn getScenarioGridColumnLocal(ScenarioSimulationBuilders.HeaderBuilder headerBuilder, String placeHolder) { return scenarioGridColumnMock; } }); scenarioGrid.setEventBus(eventBusMock); }
@Test public void cloneFactMapping() { FactMapping original = new FactMapping("FACT_ALIAS", new FactIdentifier("FI_TEST", "com.test.Foo"), new ExpressionIdentifier("EI_TEST", FactMappingType.GIVEN)); original.addExpressionElement("FIRST_STEP", String.class.getName()); original.setExpressionAlias("EA_TEST"); FactMapping retrieved = original.cloneFactMapping(); assertTrue(retrieved.equals(original)); }
@Test public void cloneFactMapping() { FactMapping original = new FactMapping("FACT_ALIAS", new FactIdentifier("FI_TEST", "com.test.Foo"), new ExpressionIdentifier("EI_TEST", FactMappingType.GIVEN)); original.addExpressionElement("FIRST_STEP", String.class.getName()); original.setExpressionAlias("EA_TEST"); FactMapping retrieved = original.cloneFactMapping(); assertTrue(retrieved.equals(original)); }