-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimised, refactored and improved tests and achieved 100% class and …
…method test coverage; Added jupiter test suite for controller test execution order; Updated junit-jupiter version to 5.11.0
- Loading branch information
1 parent
1bad055
commit 803b654
Showing
14 changed files
with
505 additions
and
248 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
.../java/dev/markodojkic/softwaredevelopmentsimulation/test/Config/GlobalSetupExtension.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package dev.markodojkic.softwaredevelopmentsimulation.test.Config; | ||
|
||
import dev.markodojkic.softwaredevelopmentsimulation.util.Utilities; | ||
import org.apache.commons.io.FileUtils; | ||
import org.junit.jupiter.api.extension.AfterAllCallback; | ||
import org.junit.jupiter.api.extension.BeforeAllCallback; | ||
import org.junit.jupiter.api.extension.ExtensionContext; | ||
|
||
import static dev.markodojkic.softwaredevelopmentsimulation.util.DataProvider.setupDataProvider; | ||
|
||
public class GlobalSetupExtension implements BeforeAllCallback, AfterAllCallback { | ||
@Override | ||
public void beforeAll(ExtensionContext extensionContext) { | ||
setupDataProvider(); | ||
} | ||
|
||
@Override | ||
public void afterAll(ExtensionContext context) throws Exception { | ||
FileUtils.deleteDirectory(Utilities.getCurrentApplicationDataPath().toAbsolutePath().toFile()); | ||
} | ||
} |
93 changes: 93 additions & 0 deletions
93
...c/softwaredevelopmentsimulation/test/Config/SoftwareDevelopmentSimulationAppBaseTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package dev.markodojkic.softwaredevelopmentsimulation.test.Config; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import dev.markodojkic.softwaredevelopmentsimulation.DeveloperImpl; | ||
import dev.markodojkic.softwaredevelopmentsimulation.ProjectManagerImpl; | ||
import dev.markodojkic.softwaredevelopmentsimulation.config.MiscellaneousConfig; | ||
import dev.markodojkic.softwaredevelopmentsimulation.config.SpringIntegrationMessageChannelsConfig; | ||
import dev.markodojkic.softwaredevelopmentsimulation.flow.FileHandlingFlow; | ||
import dev.markodojkic.softwaredevelopmentsimulation.flow.MQTTFlow; | ||
import dev.markodojkic.softwaredevelopmentsimulation.flow.PrintoutFlow; | ||
import dev.markodojkic.softwaredevelopmentsimulation.interfaces.IGateways; | ||
import dev.markodojkic.softwaredevelopmentsimulation.model.DevelopmentTeamCreationParameters; | ||
import dev.markodojkic.softwaredevelopmentsimulation.transformer.PrinterTransformer; | ||
import dev.markodojkic.softwaredevelopmentsimulation.util.Utilities; | ||
import dev.markodojkic.softwaredevelopmentsimulation.web.DevelopersPageController; | ||
import dev.markodojkic.softwaredevelopmentsimulation.web.MainController; | ||
import io.moquette.broker.Server; | ||
import io.moquette.broker.config.MemoryConfig; | ||
import org.junit.jupiter.api.AfterAll; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.beans.factory.annotation.Qualifier; | ||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.test.context.ContextConfiguration; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.util.Properties; | ||
|
||
import static dev.markodojkic.softwaredevelopmentsimulation.util.DataProvider.setupDataProvider; | ||
import static dev.markodojkic.softwaredevelopmentsimulation.util.DataProvider.updateDevelopmentTeamsSetup; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
@SpringBootTest | ||
@AutoConfigureMockMvc // Enables MockMvc with full context | ||
//@ComponentScan(basePackages = "dev.markodojkic.softwaredevelopmentsimulation") | ||
@ContextConfiguration(classes = { MiscellaneousConfig.class, TestConfig.class, SpringIntegrationMessageChannelsConfig.class, MQTTFlow.class, PrintoutFlow.class, FileHandlingFlow.class, PrinterTransformer.class, DeveloperImpl.class, ProjectManagerImpl.class, MainController.class, DevelopersPageController.class }) | ||
@ExtendWith(MockitoExtension.class) | ||
@ExtendWith(GlobalSetupExtension.class) | ||
public abstract class SoftwareDevelopmentSimulationAppBaseTest { | ||
private static Server mqttServer; | ||
|
||
@Autowired | ||
@Qualifier("IGateways") | ||
private IGateways iGateways; | ||
|
||
@Autowired | ||
private ObjectMapper objectMapper; | ||
|
||
@BeforeAll | ||
public static void preSetup() throws Exception { | ||
Properties properties = new Properties(); | ||
properties.setProperty("port", "21681"); | ||
properties.setProperty("host", "0.0.0.0"); | ||
properties.setProperty("password_file", ""); //No password | ||
properties.setProperty("allow_anonymous", "true"); | ||
properties.setProperty("netty.mqtt.message_size", "102400"); | ||
|
||
MemoryConfig memoryConfig = new MemoryConfig(properties); | ||
mqttServer = new Server(); | ||
mqttServer.startServer(memoryConfig); //In memory MQTT server | ||
} | ||
|
||
@AfterAll | ||
public static void tearDown() { | ||
mqttServer.stopServer(); | ||
} | ||
|
||
@BeforeEach | ||
public void setup() throws IOException { | ||
assertNotNull(iGateways); | ||
Utilities.setIGateways(iGateways); | ||
assertNotNull(Utilities.getIGateways()); | ||
Utilities.setObjectMapper(objectMapper); | ||
setupDataProvider(); | ||
updateDevelopmentTeamsSetup(new DevelopmentTeamCreationParameters()); | ||
|
||
Files.createDirectories(Utilities.getCurrentApplicationDataPath()); | ||
Files.createDirectories(Utilities.getCurrentApplicationLogsPath()); | ||
} | ||
|
||
@BeforeEach | ||
public void setUp() { | ||
// Common setup code here | ||
// e.g., initializing beans, setting up data | ||
setupDataProvider(); | ||
updateDevelopmentTeamsSetup(new DevelopmentTeamCreationParameters()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.