Skip to content

Commit

Permalink
Fixed static mocking error in ReconcilerMainTest
Browse files Browse the repository at this point in the history
  • Loading branch information
ctevse committed Nov 2, 2023
1 parent 3098385 commit 3d3c21f
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions reconciler/src/test/java/edu/rit/se/nvip/ReconcilerMainTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import edu.rit.se.nvip.messenger.Messenger;
import edu.rit.se.nvip.utils.ReconcilerEnvVars;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
Expand Down Expand Up @@ -33,6 +34,12 @@ void initMocks(){
mockedEnvVars = mockStatic(ReconcilerEnvVars.class);
}

@AfterEach
void clearMocks(){
mockedDb.close();
mockedEnvVars.close();
}

//verifies that the main can properly get jobs and process them for the reconciler controller, this tests both rabbit and db
@Test
void testMainWithDb() {
Expand All @@ -53,9 +60,6 @@ void testMainWithDb() {
doNothing().when(mockCon).main(anySet());
//test for db
main.main();

mockedEnvVars.close();
mockedDb.close();
}

@Test
Expand All @@ -71,9 +75,6 @@ void testMainWithDbNoJobs() {

when(mockDb.getJobs()).thenReturn(null);
main.main();

mockedEnvVars.close();
mockedDb.close();
}

@Test
Expand All @@ -100,9 +101,6 @@ void testMainWithRabbit() {
doNothing().when(mockCon).main(anySet());

main.main();

mockedEnvVars.close();
mockedDb.close();
}

@Test
Expand All @@ -127,8 +125,5 @@ void testMainWithRabbitNoMessages() {
fail("Caught Unexpected exception");
}
main.main();

mockedEnvVars.close();
mockedDb.close();
}
}

0 comments on commit 3d3c21f

Please sign in to comment.