Skip to content

Commit

Permalink
address few more review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmadshadab committed Sep 27, 2024
1 parent f9426f3 commit 5b08cde
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
46 changes: 23 additions & 23 deletions core-common/src/test/java/org/uniprot/core/util/UtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -191,71 +191,71 @@ void nonEmpty_shouldAlwaysReturnFalse() {
class unmodifiableList {
@Test
void passingNullReturnEmptyList() {
List l = Utils.unmodifiableList(null);
assertTrue(l.isEmpty());
List<Object> unmodifiableList = Utils.unmodifiableList(null);
assertTrue(unmodifiableList.isEmpty());
}

@Test
void passing_emptyList_returnEmptyList() {
List l = Utils.unmodifiableList(new ArrayList<>());
assertTrue(l.isEmpty());
List<Object> unmodifiableList = Utils.unmodifiableList(new ArrayList<>());
assertTrue(unmodifiableList.isEmpty());
}

@Test
void passingNullReturnEmptyList_unmodifiable() {
List<String> l = Utils.unmodifiableList(null);
assertThrows(UnsupportedOperationException.class, () -> l.add("abc"));
List<String> unmodifiableList = Utils.unmodifiableList(null);
assertThrows(UnsupportedOperationException.class, () -> unmodifiableList.add("abc"));
}

@Test
void passing_emptyList_returnEmptyList_unmodifiable() {
List<String> l = Utils.unmodifiableList(new ArrayList<>());
assertThrows(UnsupportedOperationException.class, () -> l.add("abc"));
List<String> unmodifiableList = Utils.unmodifiableList(new ArrayList<>());
assertThrows(UnsupportedOperationException.class, () -> unmodifiableList.add("abc"));
}

@Test
void passingList_returnUnmodifiable() {
List<String> list = new ArrayList<>();
list.add("a");
list.add("b");
List<String> l = Utils.unmodifiableList(list);
assertThrows(UnsupportedOperationException.class, () -> l.add("c"));
List<String> unmodifiableList = Utils.unmodifiableList(list);
assertThrows(UnsupportedOperationException.class, () -> unmodifiableList.add("c"));
}
}

@Nested
class unmodifiableSet {
@Test
void passingNullReturnEmptySet() {
Set l = Utils.unmodifiableSet(null);
assertTrue(l.isEmpty());
Set<Object> unmodifiableSet = Utils.unmodifiableSet(null);
assertTrue(unmodifiableSet.isEmpty());
}

@Test
void passing_emptySet_returnEmptySet() {
Set l = Utils.unmodifiableSet(new HashSet<>());
assertTrue(l.isEmpty());
Set<String> unmodifiableSet = Utils.unmodifiableSet(new HashSet<>());
assertTrue(unmodifiableSet.isEmpty());
}

@Test
void passingNullReturnEmptySet_unmodifiable() {
Set<String> l = Utils.unmodifiableSet(null);
assertThrows(UnsupportedOperationException.class, () -> l.add("abc"));
Set<String> unmodifiableSet = Utils.unmodifiableSet(null);
assertThrows(UnsupportedOperationException.class, () -> unmodifiableSet.add("abc"));
}

@Test
void passing_emptySet_returnEmptySet_unmodifiable() {
Set<String> l = Utils.unmodifiableSet(new HashSet<>());
assertThrows(UnsupportedOperationException.class, () -> l.add("abc"));
Set<String> unmodifiableSet = Utils.unmodifiableSet(new HashSet<>());
assertThrows(UnsupportedOperationException.class, () -> unmodifiableSet.add("abc"));
}

@Test
void passingSet_returnUnmodifiable() {
Set<String> list = new HashSet<>();
list.add("a");
list.add("b");
Set<String> l = Utils.unmodifiableSet(list);
assertThrows(UnsupportedOperationException.class, () -> l.add("c"));
Set<String> set = new HashSet<>();
set.add("a");
set.add("b");
Set<String> unmodifiableSet = Utils.unmodifiableSet(set);
assertThrows(UnsupportedOperationException.class, () -> unmodifiableSet.add("c"));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,17 +212,17 @@ void testGeneNamesAdd() {
}

@Test
void testProteomeIdsSet() {
void testProteomesSet() {
LinkedHashSet<Proteome> proteomes = new LinkedHashSet<>(List.of(new ProteomeBuilder().id("UP000005640").component("C1").build(), new ProteomeBuilder().id("UP000002494").component("C2").build()));
UniParcEntryLight entry = new UniParcEntryLightBuilder().proteomesSet(proteomes).build();
assertEquals(proteomes, entry.getProteomes());
}

@Test
void testProteomeIdsAdd() {
Proteome proteomeId = new ProteomeBuilder().id("UP000005640").component("C1").build();
UniParcEntryLight entry = new UniParcEntryLightBuilder().proteomesAdd(proteomeId).build();
assertTrue(entry.getProteomes().contains(proteomeId));
void testProteomeAdd() {
Proteome proteome = new ProteomeBuilder().id("UP000005640").component("C1").build();
UniParcEntryLight entry = new UniParcEntryLightBuilder().proteomesAdd(proteome).build();
assertTrue(entry.getProteomes().contains(proteome));
}

@Test
Expand Down

0 comments on commit 5b08cde

Please sign in to comment.