FromAccumulateCompositeFactPatternWidget extends FromCompositeFactPatternWidget { @Override protected void showFactTypeSelector() { final ListBox box = GWT.create(ListBox.class); AsyncPackageDataModelOracle oracle = this.getModeller().getDataModelOracle(); String[] facts = oracle.getFactTypes(); box.addItem(GuidedRuleEditorResources.CONSTANTS.Choose()); for (int i = 0; i < facts.length; i++) { box.addItem(facts[i]); } box.setSelectedIndex(0); final FormStylePopup popup = new FormStylePopup(GuidedRuleEditorResources.CONSTANTS.NewFactPattern()); popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.chooseFactType(), box); box.addChangeHandler(new ChangeHandler() { public void onChange(ChangeEvent event) { pattern.setFactPattern(new FactPattern(box.getItemText(box.getSelectedIndex()))); setModified(true); getModeller().refreshWidget(); popup.hide(); } }); popup.show(); } FromAccumulateCompositeFactPatternWidget(RuleModeller modeller,
                                                    EventBus eventBus,
                                                    FromAccumulateCompositeFactPattern pattern,
                                                    Boolean readOnly);  FromAccumulateCompositeFactPatternWidget(RuleModeller modeller,
                                                    EventBus eventBus,
                                                    FromAccumulateCompositeFactPattern pattern);   }
@Test public void testShowFactTypeSelectorFactsInSamePackage() throws Exception { dataModelPayload.setPackageName(REDHAT_PACKAGE); asyncPackageDataModelOracleFactory.makeAsyncPackageDataModelOracle(resourcePath, dataModelPayload); fromAccumulateWidget.showFactTypeSelector(); verify(listBox).addItem(GuidedRuleEditorResources.CONSTANTS.Choose()); verify(listBox).addItem(FACT_TYPE_PERSON); verify(listBox).addItem(FACT_TYPE_CAR); verify(listBox, times(3)).addItem(anyString()); }
@Test public void testShowFactTypeSelectorFactsNotInSamePackage() throws Exception { dataModelPayload.setPackageName(REDHAT_SUBPACKAGE); asyncPackageDataModelOracleFactory.makeAsyncPackageDataModelOracle(resourcePath, dataModelPayload); fromAccumulateWidget.showFactTypeSelector(); verify(listBox).addItem(GuidedRuleEditorResources.CONSTANTS.Choose()); verify(listBox, times(1)).addItem(anyString()); }
@Test public void testShowFactTypeSelectorFactsInSamePackageAndImportedNumber() throws Exception { dataModelPayload.setPackageName(REDHAT_PACKAGE); asyncPackageDataModelOracleFactory.makeAsyncPackageDataModelOracle( resourcePath, ruleModelWithImportedNumber, dataModelPayload); fromAccumulateWidget.showFactTypeSelector(); verify(listBox).addItem(GuidedRuleEditorResources.CONSTANTS.Choose()); verify(listBox).addItem(FACT_TYPE_PERSON); verify(listBox).addItem(FACT_TYPE_CAR); verify(listBox).addItem(Number.class.getSimpleName()); verify(listBox, times(4)).addItem(anyString()); }
@Test public void testShowFactTypeSelectorFactsNotInSamePackageAndImportedNumber() throws Exception { dataModelPayload.setPackageName(REDHAT_SUBPACKAGE); asyncPackageDataModelOracleFactory.makeAsyncPackageDataModelOracle( resourcePath, ruleModelWithImportedNumber, dataModelPayload); fromAccumulateWidget.showFactTypeSelector(); verify(listBox).addItem(GuidedRuleEditorResources.CONSTANTS.Choose()); verify(listBox).addItem(Number.class.getSimpleName()); verify(listBox, times(2)).addItem(anyString()); }