@Override public List<ValidationMessage> validate(final Path path, final GuidedDecisionTable52 content) { try { return genericValidator.validate(path, GuidedDTXMLPersistence.getInstance().marshal(content)); } catch (Exception e) { throw ExceptionUtilities.handleException(e); } }
@Before public void setUp() throws Exception { GuidedDTXMLPersistence.getInstance(); }
@Override public GuidedDecisionTable52 load(final Path path) { try { final String content = ioService.readAllString(Paths.convert(path)); return GuidedDTXMLPersistence.getInstance().unmarshal(content); } catch (Exception e) { throw ExceptionUtilities.handleException(e); } }
@Override public ResourceConversionResult loadFromInputStream(InputStream is) throws IOException { String xml = new String(IoUtils.readBytesFromInputStream(is), IoUtils.UTF8_CHARSET); GuidedDecisionTable52 model = GuidedDTXMLPersistence.getInstance().unmarshal(xml); String content = GuidedDTDRLPersistence.getInstance().marshal(model); if (hasDSLSentences(model)) { return new ResourceConversionResult(content, ResourceType.DSLR); } else { return new ResourceConversionResult(content, ResourceType.DRL); } }
@Override public IndexBuilder fillIndexBuilder(final Path path) throws Exception { final String content = ioService.readAllString(path); final GuidedDecisionTable52 model = GuidedDTXMLPersistence.getInstance().unmarshal(content); final String drl = GuidedDTDRLPersistence.getInstance().marshal(model); return fillDrlIndexBuilder(path, drl); }
@Test public void testRoundTrip() { final GuidedDecisionTable52 dt = new GuidedDecisionTable52(); dt.setHitPolicy( GuidedDecisionTable52.HitPolicy.FIRST_HIT ); final String xml = GuidedDTXMLPersistence.getInstance() .marshal( dt ); assertNotNull( xml ); assertTrue( xml.contains( "<hitPolicy>FIRST_HIT</hitPolicy>" ) ); final GuidedDecisionTable52 dt_ = GuidedDTXMLPersistence.getInstance() .unmarshal( xml ); assertEquals( GuidedDecisionTable52.HitPolicy.FIRST_HIT, dt_.getHitPolicy() ); }
protected void analyze(String resourceName) throws Exception { final String xml = TestUtil.loadResource(resourceName); final GuidedDecisionTable52 table52 = GuidedDTXMLPersistence.getInstance().unmarshal(xml); final Analyzer analyzer = analyzerProvider.makeAnalyser(table52); // First run analyzer.resetChecks(); analyzer.analyze(); }
protected void analyze(String resourceName) throws Exception { final String xml = TestUtil.loadResource(resourceName); final GuidedDecisionTable52 table52 = GuidedDTXMLPersistence.getInstance().unmarshal(xml); final Analyzer analyzer = analyzerProvider.makeAnalyser(table52); // First run analyzer.resetChecks(); analyzer.analyze(); }
@Test public void testFileBaseEntitlementGDST() throws Exception { final String xml = loadResource("Base entitlement.gdst"); final Analyzer analyzer = analyzerProvider.makeAnalyser(GuidedDTXMLPersistence.getInstance() .unmarshal(xml)); analyzer.resetChecks(); analyzer.analyze(); assertTrue(analyzerProvider.getAnalysisReport() .isEmpty()); }
@Test public void testFileBaseEntitlementGDST() throws Exception { final String xml = loadResource("Base entitlement.gdst"); final Analyzer analyzer = analyzerProvider.makeAnalyser(GuidedDTXMLPersistence.getInstance() .unmarshal(xml)); analyzer.resetChecks(); analyzer.analyze(); assertTrue(analyzerProvider.getAnalysisReport() .isEmpty()); }
@Test public void testBackwardsCompatibility() throws Exception { final String xml = loadResource( "ExistingDecisionTable.xml" ); final GuidedDecisionTable52 dt_ = GuidedDTXMLPersistence.getInstance() .unmarshal( xml ); assertNotNull( dt_ ); assertEquals( GuidedDecisionTable52.HitPolicy.NONE, dt_.getHitPolicy() ); }
@Test public void testRuleTableGDSTWorkItem() throws Exception { final String xml = loadResource("WorkItem.gdst"); final GuidedDecisionTable52 table52 = GuidedDTXMLPersistence.getInstance() .unmarshal(xml); final Analyzer analyzer = analyzerProvider.makeAnalyser(table52); analyzer.resetChecks(); analyzer.analyze(); final Set<Issue> analysisReport = analyzerProvider.getAnalysisReport(); assertTrue(analysisReport.isEmpty()); } }
@Test public void testLHSConflictsArePickedUpForEachFieldOfAPatternTheFileFromTicket() throws Exception { final String xml = loadResource("GUVNOR-3513-second-version.gdst"); final GuidedDecisionTable52 table52 = GuidedDTXMLPersistence.getInstance() .unmarshal(xml); final Analyzer analyzer = analyzerProvider.makeAnalyser(table52); analyzer.resetChecks(); analyzer.analyze(); assertResultIsEmpty(analyzerProvider.getAnalysisReport()); }
@Test public void testLHSConflictsArePickedUpForEachFieldOfAPatternTheFileFromTicket() throws Exception { final String xml = loadResource("GUVNOR-3513-second-version.gdst"); final GuidedDecisionTable52 table52 = GuidedDTXMLPersistence.getInstance() .unmarshal(xml); final Analyzer analyzer = analyzerProvider.makeAnalyser(table52); analyzer.resetChecks(); analyzer.analyze(); assertResultIsEmpty(analyzerProvider.getAnalysisReport()); }
@Test public void testLHSConflictsArePickedUpForEachFieldOfAPattern() throws Exception { final String xml = loadResource("GUVNOR-3513.gdst"); final GuidedDecisionTable52 table52 = GuidedDTXMLPersistence.getInstance() .unmarshal(xml); final Analyzer analyzer = analyzerProvider.makeAnalyser(table52); analyzer.resetChecks(); analyzer.analyze(); assertResultIsEmpty(analyzerProvider.getAnalysisReport()); }
@Test public void testLHSConflictsArePickedUpForEachFieldOfAPattern() throws Exception { final String xml = loadResource("GUVNOR-3513.gdst"); final GuidedDecisionTable52 table52 = GuidedDTXMLPersistence.getInstance() .unmarshal(xml); final Analyzer analyzer = analyzerProvider.makeAnalyser(table52); analyzer.resetChecks(); analyzer.analyze(); assertResultIsEmpty(analyzerProvider.getAnalysisReport()); }
@Test public void testFileLargeFileGDST() throws Exception { final String xml = loadResource("Large file.gdst"); final Analyzer analyzer = analyzerProvider.makeAnalyser(GuidedDTXMLPersistence.getInstance() .unmarshal(xml)); analyzer.resetChecks(); analyzer.analyze(); assertOnlyContains(analyzerProvider.getAnalysisReport(), CheckType.SINGLE_HIT_LOST, CheckType.EMPTY_RULE); }
@Test public void testFileLargeFileGDST() throws Exception { final String xml = loadResource("Large file.gdst"); final Analyzer analyzer = analyzerProvider.makeAnalyser(GuidedDTXMLPersistence.getInstance() .unmarshal(xml)); analyzer.resetChecks(); analyzer.analyze(); assertOnlyContains(analyzerProvider.getAnalysisReport(), CheckType.SINGLE_HIT_LOST, CheckType.EMPTY_RULE); }
@Test @Ignore public void testFile3() throws Exception { final String xml = loadResource("Pricing loans version 2.gdst"); final GuidedDecisionTable52 table52 = GuidedDTXMLPersistence.getInstance() .unmarshal(xml); final Analyzer analyzer = analyzerProvider.makeAnalyser(table52); analyzer.resetChecks(); analyzer.analyze(); assertDoesNotContain(CheckType.REDUNDANT_ROWS, analyzerProvider.getAnalysisReport()); }
@Test @Ignore("list of admitted values is in the model and currently not accessible for the analyzer") public void testFilePricingLoansGDST() throws Exception { final String xml = loadResource("Pricing loans.gdst"); final GuidedDecisionTable52 table52 = GuidedDTXMLPersistence.getInstance() .unmarshal(xml); final Analyzer analyzer = analyzerProvider.makeAnalyser(table52); analyzer.resetChecks(); analyzer.analyze(); assertOnlyContains(analyzerProvider.getAnalysisReport(), CheckType.MISSING_RANGE); }