### Question:
EntityhubLDPath extends LDPath<Object> { public Representation execute(Reference context,Program<Object> program){ if(context == null){ throw new IllegalArgumentException("The parsed context MUST NOT be NULL!"); } if(program == null){ throw new IllegalArgumentException("The parsed program MUST NOT be NULL!"); } Representation result = vf.createRepresentation(context.getReference()); for(FieldMapping<?,Object> mapping : program.getFields()) { Collection<?> values = mapping.getValues(backend,context); if(values !=null && !values.isEmpty()){ result.add(mapping.getFieldName(),values); } } return result; } EntityhubLDPath(RDFBackend<Object> backend);  EntityhubLDPath(RDFBackend<Object> backend,ValueFactory vf); Representation execute(Reference context,Program<Object> program);  }### Answer:
@Test public void testTransformers() throws Exception { EntityhubLDPath ldPath = new EntityhubLDPath(backend); Program<Object> program = ldPath.parseProgram( getReader(DATA_TYPE_TEST_PROGRAM)); assertNotNull("The Program MUST NOT be NULL", program); Map<String,Collection<?>> result = program.execute(backend, vf.createReference(CONTEXT_LONDON)); log.info("Results for {}:\n{}",CONTEXT_LONDON,result); log.info("Assert LDPath Result for {}:", CONTEXT_LONDON); assertLDPathResult(result, EXPECTED_RESULTS_LONDON); }
@Test public void testReprentationMappings() throws Exception { EntityhubLDPath ldPath = new EntityhubLDPath(backend); Program<Object> program = ldPath.parseProgram( getReader(DATA_TYPE_TEST_PROGRAM)); assertNotNull("The Program MUST NOT be NULL", program); Representation result = ldPath.execute( vf.createReference(CONTEXT_LONDON), program); assertEquals("The id of the Representation '"+ result.getId()+"' is not the same as the parsed Context '"+ CONTEXT_LONDON+"'!", CONTEXT_LONDON, result.getId()); Iterator<Entry<String,Collection<?>>> entryIt = cloneExpected(EXPECTED_RESULTS_LONDON).entrySet().iterator(); while(entryIt.hasNext()){ Entry<String,Collection<?>> entry = entryIt.next(); Iterator<Object> valueIt = result.get(entry.getKey()); assertNotNull("The result is missing the expected field '"+ entry.getKey()+"'!",valueIt); Collection<Object> values = ModelUtils.asCollection(valueIt); entry.getValue().removeAll(values); assertTrue("The following expected values "+ entry.getValue()+"' are missing (present: "+ values+")!",entry.getValue().isEmpty()); } }