diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 27c54a6e..d6c88979 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -30,16 +30,10 @@ jobs: run: mvn -DskipTests -B install --file pom.xml - name: Check Formatting - run: mvn -DskipTests verify + run: mvn -DskipTests -B verify - - name: Check Jobs Tests - run: cd services/jobs && mvn test - - - name: Check Users Tests - run: cd services/users && mvn test - - - name: Check Payments Tests - run: cd services/payments && mvn test + - name: Check Tests + run: mvn -B test - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v4.0.1 diff --git a/pom.xml b/pom.xml index c85af379..7ce7de75 100644 --- a/pom.xml +++ b/pom.xml @@ -72,6 +72,26 @@ + + org.jacoco + jacoco-maven-plugin + 0.8.12 + + + prepare-agent + + prepare-agent + + + + report + test + + report + + + + diff --git a/services/contracts/pom.xml b/services/contracts/pom.xml index baa8376c..5151108f 100644 --- a/services/contracts/pom.xml +++ b/services/contracts/pom.xml @@ -114,6 +114,26 @@ + + org.jacoco + jacoco-maven-plugin + 0.8.12 + + + prepare-agent + + prepare-agent + + + + report + test + + report + + + + \ No newline at end of file diff --git a/services/contracts/src/test/java/com/workup/contracts/ContractsApplicationTests.java b/services/contracts/src/test/java/com/workup/contracts/ContractsApplicationTests.java index ac6e5ec8..273c7261 100644 --- a/services/contracts/src/test/java/com/workup/contracts/ContractsApplicationTests.java +++ b/services/contracts/src/test/java/com/workup/contracts/ContractsApplicationTests.java @@ -1,95 +1,6 @@ package com.workup.contracts; -import com.workup.contracts.repositories.ContractMilestoneRepository; -import com.workup.contracts.repositories.ContractRepository; -import com.workup.contracts.repositories.TerminationRequestRepository; -import java.text.ParseException; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.springframework.amqp.core.AmqpTemplate; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.context.annotation.Import; -import org.springframework.test.context.DynamicPropertyRegistry; -import org.springframework.test.context.DynamicPropertySource; -import org.testcontainers.containers.CassandraContainer; -import org.testcontainers.containers.RabbitMQContainer; -import org.testcontainers.junit.jupiter.Container; -import org.testcontainers.junit.jupiter.Testcontainers; @SpringBootTest -@Testcontainers -@Import(TestConfigBase.class) -class ContractsApplicationTests { - - @Container - static CassandraContainer cassandraContainer = - new CassandraContainer<>("cassandra:4.0.7").withConfigurationOverride("cassandra-config"); - - @Container - static RabbitMQContainer rabbitMQContainer = new RabbitMQContainer("rabbitmq:3.13-management"); - - static String GetCassandraContactPoint() { - return cassandraContainer.getHost() + ":" + cassandraContainer.getFirstMappedPort(); - } - - @DynamicPropertySource - static void datasourceProperties(DynamicPropertyRegistry registry) { - registry.add( - "spring.cassandra.contact-points", ContractsApplicationTests::GetCassandraContactPoint); - - registry.add("spring.rabbitmq.host", rabbitMQContainer::getHost); - registry.add("spring.rabbitmq.port", rabbitMQContainer::getFirstMappedPort); - registry.add("spring.rabbitmq.username", rabbitMQContainer::getAdminUsername); - registry.add("spring.rabbitmq.password", rabbitMQContainer::getAdminPassword); - } - - private static final String CLIENT_ONE_ID = "123"; - private static final String CLIENT_TWO_ID = "456"; - private static final String FREELANCER_ONE_ID = "789"; - - @Autowired AmqpTemplate template; - @Autowired ContractRepository contractRepository; - @Autowired ContractMilestoneRepository contractMilestoneRepository; - @Autowired TerminationRequestRepository terminationRequestRepository; - - @BeforeEach - void clearAll() { - contractRepository.deleteAll(); - contractMilestoneRepository.deleteAll(); - terminationRequestRepository.deleteAll(); - } - - /** - * Creates a job request. - * - * @throws ParseException - */ - @Test - void testCreateJob() { - // Example test from jobs - // CreateJobRequest createJobRequest = - // CreateJobRequest.builder() - // .withTitle("Convert HTML Template to React 3") - // .withDescription( - // "I have an HTML template that I have purchased and own the rights - // to. I would like" - // + " it converted into a React application.") - // .withSkills(new String[] {"HTML", "CSS", "JavaScript", "React"}) - // .withUserId(CLIENT_ONE_ID) - // .build(); - // - // CreateJobResponse response = - // (CreateJobResponse) - // template.convertSendAndReceive(ServiceQueueNames.JOBS, createJobRequest); - // - // assertNotNull(response); - // assertTrue(response.getStatusCode() == HttpStatusCode.CREATED); - // - // jobRepository - // .findById(UUID.fromString(response.getJobId())) - // .ifPresentOrElse( - // job -> assertTrue(job.getTitle().equals(createJobRequest.getTitle())), - // () -> new RuntimeException("Job not found")); - } -} +class ContractsApplicationTests {} diff --git a/services/contracts/src/test/java/com/workup/contracts/TestConfigBase.java b/services/contracts/src/test/java/com/workup/contracts/TestConfigBase.java deleted file mode 100644 index acf2801d..00000000 --- a/services/contracts/src/test/java/com/workup/contracts/TestConfigBase.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.workup.contracts; - -import com.workup.shared.enums.ServiceQueueNames; -import org.springframework.amqp.core.Queue; -import org.springframework.boot.test.context.TestConfiguration; -import org.springframework.context.annotation.Bean; - -@TestConfiguration -public class TestConfigBase { - @Bean - public Queue contractsQueueMock() { - return new Queue(ServiceQueueNames.CONTRACTS); - } -} diff --git a/services/jobs/pom.xml b/services/jobs/pom.xml index d6d51d0f..79a167b3 100644 --- a/services/jobs/pom.xml +++ b/services/jobs/pom.xml @@ -146,6 +146,26 @@ + + org.jacoco + jacoco-maven-plugin + 0.8.12 + + + prepare-agent + + prepare-agent + + + + report + test + + report + + + + \ No newline at end of file diff --git a/services/payments/pom.xml b/services/payments/pom.xml index 979a6b16..772c50e8 100644 --- a/services/payments/pom.xml +++ b/services/payments/pom.xml @@ -149,6 +149,26 @@ + + org.jacoco + jacoco-maven-plugin + 0.8.12 + + + prepare-agent + + prepare-agent + + + + report + test + + report + + + + \ No newline at end of file diff --git a/services/users/pom.xml b/services/users/pom.xml index fade9f78..ccba08e2 100644 --- a/services/users/pom.xml +++ b/services/users/pom.xml @@ -180,6 +180,26 @@ + + org.jacoco + jacoco-maven-plugin + 0.8.12 + + + prepare-agent + + prepare-agent + + + + report + test + + report + + + +