### Question:
SearchResponseV2_1RefAdder { public void addRef(SearchResponseV2_1 searchResponse, EntityRef entityRef) { SearchResponseV2_1Ref searchResponseRef; if (entityRef.getType().equals("wwrelation")) { searchResponseRef = new SearchResponseV2_1Ref( entityRef.getId(), entityRef.getType(), createPath(entityRef), entityRef.getSourceName(), entityRef.getSourceData(), entityRef.getTargetName(), entityRef.getTargetData(), entityRef.getRelationName()); } else { searchResponseRef = new SearchResponseV2_1Ref( entityRef.getId(), entityRef.getType(), createPath(entityRef), entityRef.getDisplayName(), entityRef.getData()); } searchResponse.addRef(searchResponseRef); }  void addRef(SearchResponseV2_1 searchResponse, EntityRef entityRef);  }### Answer:
@Test public void addsASearchResponseRefToTheSearchResult() { SearchResponseV2_1RefAdder instance = new SearchResponseV2_1RefAdder(); SearchResponseV2_1 searchResponse = new SearchResponseV2_1(); EntityRef entityRef = new EntityRef("type", "id"); entityRef.setDisplayName("displayName"); instance.addRef(searchResponse, entityRef); assertThat(searchResponse.getRefs(), Matchers.contains( SearchResponseV2_1RefMatcher.likeSearchResponseRef() .withId("id") .withType("type") .withDisplayName("displayName") .withPath("domain/types/id"))); }
@Test public void addsTheDataOfTheEntityRefToTheSearchResponseV2_1Ref() { SearchResponseV2_1RefAdder instance = new SearchResponseV2_1RefAdder(); SearchResponseV2_1 searchResponse = new SearchResponseV2_1(); EntityRef entityRef = new EntityRef("type", "id"); HashMap<String, Object> data = Maps.newHashMap(); entityRef.setData(data); instance.addRef(searchResponse, entityRef); assertThat(searchResponse.getRefs(), Matchers.contains(SearchResponseV2_1RefMatcher.likeSearchResponseRef() .withData(data))); }