BioEntityCardModelFactory { JsonArray bioentityProperties(String identifier, Species species, List<BioentityPropertyName> desiredOrderOfPropertyNames, Map<BioentityPropertyName, Set<String>> propertyValuesByType) { JsonArray result = new JsonArray(); for (BioentityPropertyName bioentityPropertyName : propertiesWeWillDisplay(desiredOrderOfPropertyNames, propertyValuesByType)) { JsonArray values = new JsonArray(); for (PropertyLink propertyLink : createLinks( identifier, bioentityPropertyName, propertyValuesByType.get(bioentityPropertyName), species)) { values.add(propertyLink.toJson()); } if (values.size() > 0) { JsonObject o = new JsonObject(); o.addProperty("type", bioentityPropertyName.name); o.addProperty("name", bioentityPropertyName.label); o.add("values", values); result.add(o); } } return result; } @Inject  BioEntityCardModelFactory(BioEntityPropertyService bioEntityPropertyService,
                                     ArrayDesignDao arrayDesignDao); Map<String, Object> modelAttributes(String identifier, Species species,
                                               List<BioentityPropertyName> orderedPropertyNames, String entityName,
                                               Map<BioentityPropertyName, Set<String>> propertyValuesByType);  }
@Test public void nullCases() { assertThat(subject.bioentityProperties(GENE_ID, SPECIES, ImmutableList.of(), ImmutableMap.of())) .isEqualTo(new JsonArray()); assertThat( subject.bioentityProperties( GENE_ID, SPECIES, ImmutableList.of(BioentityPropertyName.GO), ImmutableMap.of())) .isEqualTo(new JsonArray()); assertThat( subject.bioentityProperties( GENE_ID, SPECIES, ImmutableList.of(BioentityPropertyName.GO), ImmutableMap.of(BioentityPropertyName.PATHWAYID, ImmutableSet.of()))) .isEqualTo(new JsonArray()); assertThat( subject.bioentityProperties( GENE_ID, SPECIES, ImmutableList.of(BioentityPropertyName.GO), ImmutableMap.of(BioentityPropertyName.GO, ImmutableSet.of()))). isEqualTo(new JsonArray()); }
@Test public void outputLooksRight() { when(linkBuilderMock.mapToLinkText(BIOENTITY_PROPERTY_NAME_GO, ImmutableSet.of("value"), false)) .thenReturn(ImmutableMap.of("value", "value")); JsonArray result = subject.bioentityProperties( GENE_ID, SPECIES, ImmutableList.of(BIOENTITY_PROPERTY_NAME_GO), ImmutableMap.of(BIOENTITY_PROPERTY_NAME_GO, ImmutableSet.of("value"))); JsonObject property = result.get(0).getAsJsonObject(); assertThat(property.get("type").getAsString()).isEqualTo(BIOENTITY_PROPERTY_NAME_GO.name); assertThat(property.get("name").getAsString()).isEqualTo(BIOENTITY_PROPERTY_NAME_GO.label); JsonObject value = property.get("values").getAsJsonArray().get(0).getAsJsonObject(); assertThat(value.get("text").getAsString()).isEqualTo("value"); assertThat(value.get("url").getAsString()) .isEqualTo("https: assertThat(value.get("relevance").getAsInt()).isEqualTo(0); }