Skip to content

Commit

Permalink
Added report gen for coverage (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahmad45123 authored May 18, 2024
1 parent acdfc46 commit f57c9a7
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 113 deletions.
12 changes: 3 additions & 9 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
Expand Down
20 changes: 20 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,26 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.12</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
20 changes: 20 additions & 0 deletions services/contracts/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,26 @@
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.12</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -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 {}

This file was deleted.

20 changes: 20 additions & 0 deletions services/jobs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,26 @@
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.12</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
20 changes: 20 additions & 0 deletions services/payments/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,26 @@
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.12</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
20 changes: 20 additions & 0 deletions services/users/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,26 @@
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.12</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down

0 comments on commit f57c9a7

Please sign in to comment.