CollectionEditorSingletonDOMElementFactory extends BaseSingletonDOMElementFactory<String, CollectionViewImpl, CollectionEditorDOMElement> { protected void setCollectionEditorStructureData(CollectionViewImpl collectionEditorView, FactMapping factMapping) { String propertyClass = factMapping.getClassName(); String className = factMapping.getFactAlias(); String propertyName = factMapping.getExpressionAlias(); List<String> genericTypes = factMapping.getGenericTypes(); if (propertyClass == null || className == null || propertyName == null || genericTypes == null || genericTypes.isEmpty()) { throw new IllegalStateException("Missing required properties inside FactMapping"); } String key = className + "#" + propertyName; String genericTypeName0 = genericTypes.get(0); if (RULE.equals(scenarioSimulationContext.getSettings().getType()) && !isSimpleJavaType(genericTypeName0)) { genericTypeName0 = getRuleComplexType(genericTypeName0); } if (ScenarioSimulationSharedUtils.isList(propertyClass)) { manageList(collectionEditorView, key, genericTypeName0, scenarioSimulationContext.getSettings().getType()); } else { manageMap(collectionEditorView, key, genericTypeName0, genericTypes.get(1), scenarioSimulationContext.getSettings().getType()); } } CollectionEditorSingletonDOMElementFactory(final GridLienzoPanel gridPanel,
                                                      final GridLayer gridLayer,
                                                      final GridWidget gridWidget,
                                                      final ScenarioSimulationContext scenarioSimulationContext,
                                                      final ViewsProvider viewsProvider); @Override CollectionViewImpl createWidget(); @Override CollectionEditorDOMElement createDomElement(final GridLayer gridLayer,
                                                       final GridWidget gridWidget); @Override CollectionEditorDOMElement createDomElementInternal(final CollectionViewImpl collectionEditorView,
                                                               final GridLayer gridLayer,
                                                               final GridWidget gridWidget); @Override void registerHandlers(final CollectionViewImpl widget, final CollectionEditorDOMElement widgetDomElement);  }
@Test(expected = IllegalStateException.class) public void setCollectionEditorStructureData_EmptyPropertyClass() { when(factMappingMock.getExpressionAlias()).thenReturn(MAP_CLASS_NAME); setCollectionEditorStructureData(); }
@Test public void setCollectionEditorStructureData_ManageMapRuleSimpleType() { when(factMappingMock.getExpressionAlias()).thenReturn(MAP_CLASS_NAME); when(factMappingMock.getClassName()).thenReturn(MAP_CLASS_NAME); settingsLocal.setType(RULE); setCollectionEditorStructureData(); }
@Test public void setCollectionEditorStructureData_ManageMapRule_NotSimpleType() { when(factMappingMock.getExpressionAlias()).thenReturn(MAP_CLASS_NAME); when(factMappingMock.getClassName()).thenReturn(MAP_CLASS_NAME); settingsLocal.setType(RULE); factMappingMock.getGenericTypes().clear(); factMappingMock.getGenericTypes().add(FULL_CLASS_NAME); factMappingMock.getGenericTypes().add(FULL_CLASS_NAME + "1"); setCollectionEditorStructureData(); }
@Test public void setCollectionEditorStructureData_ManageMapRule() { when(factMappingMock.getExpressionAlias()).thenReturn(MAP_CLASS_NAME); when(factMappingMock.getClassName()).thenReturn(MAP_CLASS_NAME); settingsLocal.setType(RULE); setCollectionEditorStructureData(); }
@Test public void setCollectionEditorStructureData_ManageListRule() { when(factMappingMock.getExpressionAlias()).thenReturn(LIST_CLASS_NAME); when(factMappingMock.getClassName()).thenReturn(LIST_CLASS_NAME); settingsLocal.setType(RULE); setCollectionEditorStructureData(); }
@Test public void setCollectionEditorStructureData_ManageListDMN() { when(factMappingMock.getExpressionAlias()).thenReturn(LIST_CLASS_NAME); when(factMappingMock.getClassName()).thenReturn(LIST_CLASS_NAME); settingsLocal.setType(DMN); setCollectionEditorStructureData(); }