Skip to content

Commit

Permalink
refactor: remove multiple method calls when test exceptions
Browse files Browse the repository at this point in the history
Signed-off-by: Maximillian Arruda <maximillian.arruda@MBP-de-Digibee.local>
  • Loading branch information
Maximillian Arruda authored and Maximillian Arruda committed Nov 13, 2023
1 parent 0cdf402 commit ef3e720
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,14 @@ void beforeEach() {

@Test
void shouldReturnErrorOnSelectWhenThereIsNullParameter() {
Bson filter = eq("name", "Poliana");

Assertions.assertThrows(NullPointerException.class,
() -> entityManager.select(null, null));
Assertions.assertThrows(NullPointerException.class,
() -> entityManager.select(COLLECTION_NAME, null));

Assertions.assertThrows(NullPointerException.class,
() -> entityManager.select(null, eq("name", "Poliana")));
() -> entityManager.select(null, filter));
}

@Test
Expand All @@ -85,6 +86,8 @@ void shouldFindDocument() {

@Test
void shouldReturnErrorOnDeleteWhenThereIsNullParameter() {
Bson filter = eq("name", "Poliana");

Assertions.assertThrows(NullPointerException.class,
() -> entityManager.delete(null, null));
Assertions.assertThrows(NullPointerException.class,
Expand All @@ -108,6 +111,10 @@ void shouldDelete() {

@Test
void shouldReturnErrorOnAggregateWhenThereIsNullParameter() {
Bson bson = eq("name", "Poliana");
List<Bson> pipeline = Collections.singletonList(bson);
var pipelineArray = new Bson[]{bson};

Assertions.assertThrows(NullPointerException.class,
() -> entityManager.aggregate(null, (List<Bson>) null));
Assertions.assertThrows(NullPointerException.class,
Expand Down Expand Up @@ -178,12 +185,14 @@ void shouldCountWithFilter() {
@Test
void shouldReturnErrorOnCountWithInvalidFilter() {

Bson filter = eq("name", "Poliana");

Assertions.assertThrows(NullPointerException.class,
() -> entityManager.count(null, null));
Assertions.assertThrows(NullPointerException.class,
() -> entityManager.count(COLLECTION_NAME, null));
Assertions.assertThrows(NullPointerException.class,
() -> entityManager.count(null, eq("name","Poliana")));
() -> entityManager.count(null, filter));

}

Expand Down

0 comments on commit ef3e720

Please sign in to comment.