@Test public void find() { String sourceAttr0Name = "sourceAttr0"; String sourceAttr1Name = "sourceAttr1"; EntityType sourceEntityMeta = entityTypeFactory.create("source"); Attribute sourceAttr0 = attrMetaFactory.create().setName(sourceAttr0Name); Attribute sourceAttr1 = attrMetaFactory.create().setName(sourceAttr1Name); sourceEntityMeta.addAttribute(sourceAttr0); sourceEntityMeta.addAttribute(sourceAttr1); ExplainedQueryString sourceAttr0Explain = ExplainedQueryString.create("a", "b", param0Name, 1.0); ExplainedQueryString sourceAttr1Explain = ExplainedQueryString.create("a", "b", param1Name, 0.5); Hits<ExplainedAttribute> attrResults = Hits.create( Hit.create( ExplainedAttribute.create(sourceAttr0, singleton(sourceAttr0Explain), false), 1f), Hit.create( ExplainedAttribute.create(sourceAttr1, singleton(sourceAttr1Explain), false), 1f)); Stream<AlgorithmTemplate> templateStream = algorithmTemplateServiceImpl.find(attrResults); Map<String, String> model = Maps.newHashMap(); model.put(param0Name, sourceAttr0Name); model.put(param1Name, sourceAttr1Name); AlgorithmTemplate expectedAlgorithmTemplate = new AlgorithmTemplate(script0, model); assertEquals(of(expectedAlgorithmTemplate).collect(toList()), templateStream.collect(toList())); }
@Override public Stream<AlgorithmTemplate> find(Hits<ExplainedAttribute> attrMatches) { Stream<Script> jsScripts = dataService.findAll( SCRIPT, new QueryImpl<Script>().eq(TYPE, JsMagmaScriptRunner.NAME), Script.class); return jsScripts.flatMap(script -> toAlgorithmTemplate(script, attrMatches)); }
AlgorithmTemplateServiceImpl implements AlgorithmTemplateService { @Override public Stream<AlgorithmTemplate> find(Hits<ExplainedAttribute> attrMatches) { Stream<Script> jsScripts = dataService.findAll( SCRIPT, new QueryImpl<Script>().eq(TYPE, JsMagmaScriptRunner.NAME), Script.class); return jsScripts.flatMap(script -> toAlgorithmTemplate(script, attrMatches)); } }
AlgorithmTemplateServiceImpl implements AlgorithmTemplateService { @Override public Stream<AlgorithmTemplate> find(Hits<ExplainedAttribute> attrMatches) { Stream<Script> jsScripts = dataService.findAll( SCRIPT, new QueryImpl<Script>().eq(TYPE, JsMagmaScriptRunner.NAME), Script.class); return jsScripts.flatMap(script -> toAlgorithmTemplate(script, attrMatches)); } AlgorithmTemplateServiceImpl(DataService dataService); }
AlgorithmTemplateServiceImpl implements AlgorithmTemplateService { @Override public Stream<AlgorithmTemplate> find(Hits<ExplainedAttribute> attrMatches) { Stream<Script> jsScripts = dataService.findAll( SCRIPT, new QueryImpl<Script>().eq(TYPE, JsMagmaScriptRunner.NAME), Script.class); return jsScripts.flatMap(script -> toAlgorithmTemplate(script, attrMatches)); } AlgorithmTemplateServiceImpl(DataService dataService); @Override Stream<AlgorithmTemplate> find(Hits<ExplainedAttribute> attrMatches); }
AlgorithmTemplateServiceImpl implements AlgorithmTemplateService { @Override public Stream<AlgorithmTemplate> find(Hits<ExplainedAttribute> attrMatches) { Stream<Script> jsScripts = dataService.findAll( SCRIPT, new QueryImpl<Script>().eq(TYPE, JsMagmaScriptRunner.NAME), Script.class); return jsScripts.flatMap(script -> toAlgorithmTemplate(script, attrMatches)); } AlgorithmTemplateServiceImpl(DataService dataService); @Override Stream<AlgorithmTemplate> find(Hits<ExplainedAttribute> attrMatches);  }