ResultSetMappingProcessor { public void buildMapper(SparqlResultSetMapping mapping) { Objects.requireNonNull(mapping); final ResultRowMapper rowMapper = new ResultRowMapper(mapping.name()); buildVariableMappers(mapping, rowMapper); buildConstructorMappers(mapping, rowMapper); buildEntityMappers(mapping, rowMapper); manager.addMapper(rowMapper.getName(), rowMapper); } ResultSetMappingProcessor(MetamodelBuilder metamodelBuilder); void buildMapper(SparqlResultSetMapping mapping); ResultSetMappingManager getManager();  }
@Test public void buildMapperThrowsMappingExceptionWhenMappedFieldDoesNotExist() { final EntityTypeImpl<OWLClassA> etA = mock(EntityTypeImpl.class); when(builderMock.entity(OWLClassA.class)).thenReturn(etA); final FieldSpecification idField = mock(Identifier.class); when(etA.getFieldSpecification("uri")).thenReturn(idField); final String msg = "Unknown field stringAttribute."; when(etA.getFieldSpecification("stringAttribute")).thenThrow(new IllegalArgumentException(msg)); thrown.expect(SparqlResultMappingException.class); thrown.expectMessage(msg); processor.buildMapper(getMapping(WithEntityMapping.class)); }
@Test public void buildMapperThrowsMappingExceptionWhenEntityMappingTargetClassIsNotEntity() { when(builderMock.entity(OWLClassA.class)).thenReturn(null); thrown.expect(SparqlResultMappingException.class); thrown.expectMessage("Type " + OWLClassA.class + " is not a known entity type and cannot be used as @EntityResult target class."); processor.buildMapper(getMapping(WithEntityMapping.class)); }