### Question:
PropertyHelperImpl implements PropertyHelper { @Override public IndividualHelper firstIndividual() { Property property=getProperty(); if(property==null) { return null; } for(Value value:property) { if(value instanceof Individual<?,?>) { return new IndividualHelperImpl((Individual<?,?>)value); } } return null; } PropertyHelperImpl(URI propertyId, Individual<?,?> individual); @Override T firstValue(final Class<? extends T> aClazz); @Override IndividualHelper firstIndividual(); @Override T firstIndividual(final Class<? extends S> clazz); @Override IndividualPropertyHelper withLiteral(Object rawValue); @Override IndividualPropertyHelper withIndividual(Name<?> id); @Override IndividualPropertyHelper withIndividual(Name<?> id, String managerId); @Override IndividualPropertyHelper withIndividual(Name<?> id, String managerId, URI path); @Override IndividualPropertyHelper withIndividual(Name<?> id, String managerId, String path); @Override IndividualPropertyHelper withIndividual(URI id); @Override IndividualPropertyHelper withIndividual(String id); @Override IndividualPropertyHelper withIndividual(Term id);  }### Answer:
@Test public void testFirstIndividual$empty() { DataSet data=exampleDataSet(); Individual<?,?> individual = data.individualOfId(BLANK_NODE); PropertyHelperImpl sut = new PropertyHelperImpl(RDF.TYPE.as(URI.class), individual); assertThat(sut.firstIndividual(),nullValue()); }
@Test public void testFirstIndividual$clazz$empty() { DataSet data=exampleDataSet(); Individual<?,?> individual = data.individualOfId(BLANK_NODE); PropertyHelperImpl sut = new PropertyHelperImpl(RDF.TYPE.as(URI.class), individual); assertThat(sut.firstIndividual(ExternalIndividual.class),nullValue()); }
@Test public void testFirstIndividual$found() { DataSet data=exampleDataSet(); Individual<?,?> individual = data.individualOfId(BLANK_NODE); ExternalIndividual foundIndividual = data.individual(LDP.CONTAINER.as(URI.class), ExternalIndividual.class); individual.addValue(RDF.TYPE.as(URI.class), foundIndividual); PropertyHelperImpl sut = new PropertyHelperImpl(RDF.TYPE.as(URI.class), individual); assertThat(sut.firstIndividual(),notNullValue()); assertThat(Deencapsulation.getField(sut.firstIndividual(), "individual"),sameInstance((Object)foundIndividual)); }
@Test public void testFirstIndividual$clazz$found() { DataSet data=exampleDataSet(); Individual<?,?> individual = data.individualOfId(BLANK_NODE); ExternalIndividual foundIndividual = data.individual(LDP.CONTAINER.as(URI.class), ExternalIndividual.class); individual.addValue(RDF.TYPE.as(URI.class), foundIndividual); PropertyHelperImpl sut = new PropertyHelperImpl(RDF.TYPE.as(URI.class), individual); assertThat(sut.firstIndividual(ExternalIndividual.class),notNullValue()); assertThat(Deencapsulation.getField(sut.firstIndividual(), "individual"),sameInstance((Object)foundIndividual)); }
@Test public void testFirstIndividual$notFound() { DataSet data=exampleDataSet(); Individual<?,?> individual = data.individualOfId(BLANK_NODE); individual.addValue(RDF.TYPE.as(URI.class), Literals.of("a literal")); PropertyHelperImpl sut = new PropertyHelperImpl(RDF.TYPE.as(URI.class), individual); assertThat(sut.firstIndividual(),nullValue()); }
@Test public void testFirstIndividual$class$notFound() { DataSet data=exampleDataSet(); Individual<?,?> individual = data.individualOfId(BLANK_NODE); individual.addValue(RDF.TYPE.as(URI.class), Literals.of("a literal")); PropertyHelperImpl sut = new PropertyHelperImpl(RDF.TYPE.as(URI.class), individual); assertThat(sut.firstIndividual(ExternalIndividual.class),nullValue()); }