GuidedDecisionTableModelVisitor { public Set<String> getConsumedModelClasses() { final Set<String> factTypes = new HashSet<String>(); for (CompositeColumn<?> cc : model.getConditions()) { if (cc instanceof BRLConditionColumn) { final List<IPattern> definition = ((BRLConditionColumn) cc).getDefinition(); factTypes.addAll(getConditionFactTypesFromRuleModel(definition)); } else if (cc instanceof Pattern52) { factTypes.add(((Pattern52) cc).getFactType()); } } for (ActionCol52 c : model.getActionCols()) { if (c instanceof BRLActionColumn) { final List<IAction> definition = ((BRLActionColumn) c).getDefinition(); factTypes.addAll(getActionFactTypesFromRuleModel(definition)); } else if (c instanceof ActionInsertFactCol52) { factTypes.add(((ActionInsertFactCol52) c).getFactType()); } } final Set<String> fullyQualifiedClassNames = new HashSet<String>(); for (String factType : factTypes) { fullyQualifiedClassNames.add(convertToFullyQualifiedClassName(factType)); } return fullyQualifiedClassNames; } GuidedDecisionTableModelVisitor(final GuidedDecisionTable52 model); Set<String> getConsumedModelClasses();  }
@Test public void useFullClassNameAndOnlyTheClassName() { final GuidedDecisionTable52 model = new GuidedDecisionTable52(); model.getImports().addImport(new Import("org.test.AnotherPerson")); model.getImports().addImport(new Import("org.test.Person")); final Pattern52 pattern52 = mock(Pattern52.class); doReturn("Person").when(pattern52).getFactType(); model.getConditions().add(pattern52); final Set<String> consumedModelClasses = new GuidedDecisionTableModelVisitor(model).getConsumedModelClasses(); assertTrue(consumedModelClasses.contains("org.test.Person")); }
@Test @Ignore("DROOLS-4457") public void differentPackagesSameNames() { final GuidedDecisionTable52 model = new GuidedDecisionTable52(); model.getImports().addImport(new Import("org.test.demo.Person")); model.getImports().addImport(new Import("org.test.Person")); final Pattern52 pattern52 = mock(Pattern52.class); doReturn("Person").when(pattern52).getFactType(); model.getConditions().add(pattern52); final Set<String> consumedModelClasses = new GuidedDecisionTableModelVisitor(model).getConsumedModelClasses(); assertTrue(consumedModelClasses.contains("org.test.Person")); }