diff --git a/reconciler/src/test/java/edu/rit/se/nvip/ReconcilerMainTest.java b/reconciler/src/test/java/edu/rit/se/nvip/ReconcilerMainTest.java index 6dd598cc8..52c6296e6 100644 --- a/reconciler/src/test/java/edu/rit/se/nvip/ReconcilerMainTest.java +++ b/reconciler/src/test/java/edu/rit/se/nvip/ReconcilerMainTest.java @@ -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; @@ -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() { @@ -53,9 +60,6 @@ void testMainWithDb() { doNothing().when(mockCon).main(anySet()); //test for db main.main(); - - mockedEnvVars.close(); - mockedDb.close(); } @Test @@ -71,9 +75,6 @@ void testMainWithDbNoJobs() { when(mockDb.getJobs()).thenReturn(null); main.main(); - - mockedEnvVars.close(); - mockedDb.close(); } @Test @@ -100,9 +101,6 @@ void testMainWithRabbit() { doNothing().when(mockCon).main(anySet()); main.main(); - - mockedEnvVars.close(); - mockedDb.close(); } @Test @@ -127,8 +125,5 @@ void testMainWithRabbitNoMessages() { fail("Caught Unexpected exception"); } main.main(); - - mockedEnvVars.close(); - mockedDb.close(); } } \ No newline at end of file