@Test void testEvaluate() { Attribute amd = when(mock(Attribute.class).getName()).thenReturn("#CHROM").getMock(); when(amd.getDataType()).thenReturn(XREF); when(amd.hasRefEntity()).thenReturn(true); when(amd.getRefEntity()).thenReturn(refEmd); when(amd.getExpression()).thenReturn("{'Chromosome':String, 'Position':Int}"); when(amd.getEntityType()).thenReturn(mock(EntityType.class)); when(amd.getDataType()).thenReturn(XREF); ExpressionEvaluator evaluator = new MapOfStringsExpressionEvaluator(amd, emd); Entity expected = new DynamicEntity(refEmd); expected.set("Chromosome", "12"); expected.set("Position", "1"); Entity actual = (Entity) evaluator.evaluate(entity); assertTrue(EntityUtils.equals(actual, expected)); }
@Override public Object evaluate(Entity entity) { Entity result = new DynamicEntity(targetAttribute.getRefEntity()); for (Entry<String, ExpressionEvaluator> entry : evaluators.entrySet()) { result.set(entry.getKey(), entry.getValue().evaluate(entity)); } return result; }
MapOfStringsExpressionEvaluator implements ExpressionEvaluator { @Override public Object evaluate(Entity entity) { Entity result = new DynamicEntity(targetAttribute.getRefEntity()); for (Entry<String, ExpressionEvaluator> entry : evaluators.entrySet()) { result.set(entry.getKey(), entry.getValue().evaluate(entity)); } return result; } }
MapOfStringsExpressionEvaluator implements ExpressionEvaluator { @Override public Object evaluate(Entity entity) { Entity result = new DynamicEntity(targetAttribute.getRefEntity()); for (Entry<String, ExpressionEvaluator> entry : evaluators.entrySet()) { result.set(entry.getKey(), entry.getValue().evaluate(entity)); } return result; } MapOfStringsExpressionEvaluator(Attribute attribute, EntityType entityType); }
MapOfStringsExpressionEvaluator implements ExpressionEvaluator { @Override public Object evaluate(Entity entity) { Entity result = new DynamicEntity(targetAttribute.getRefEntity()); for (Entry<String, ExpressionEvaluator> entry : evaluators.entrySet()) { result.set(entry.getKey(), entry.getValue().evaluate(entity)); } return result; } MapOfStringsExpressionEvaluator(Attribute attribute, EntityType entityType); @Override Object evaluate(Entity entity); }
MapOfStringsExpressionEvaluator implements ExpressionEvaluator { @Override public Object evaluate(Entity entity) { Entity result = new DynamicEntity(targetAttribute.getRefEntity()); for (Entry<String, ExpressionEvaluator> entry : evaluators.entrySet()) { result.set(entry.getKey(), entry.getValue().evaluate(entity)); } return result; } MapOfStringsExpressionEvaluator(Attribute attribute, EntityType entityType); @Override Object evaluate(Entity entity);  }