Skip to content

Commit

Permalink
formating
Browse files Browse the repository at this point in the history
  • Loading branch information
Kemosalamy committed May 12, 2024
1 parent 1b1d006 commit d0cfc94
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
import com.workup.contracts.repositories.ContractMilestoneRepository;
import com.workup.contracts.repositories.ContractRepository;
import com.workup.contracts.repositories.TerminationRequestRepository;
import com.workup.shared.commands.jobs.requests.CreateJobRequest;
import com.workup.shared.commands.jobs.responses.CreateJobResponse;
import com.workup.shared.enums.HttpStatusCode;
import com.workup.shared.enums.ServiceQueueNames;
import java.text.ParseException;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.amqp.core.AmqpTemplate;
Expand All @@ -20,20 +17,14 @@
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;

import java.text.ParseException;
import java.util.UUID;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

@SpringBootTest
@Testcontainers
@Import(TestConfigBase.class)
class ContractsApplicationTests {

@Container
static CassandraContainer<?> cassandraContainer =
new CassandraContainer<>("cassandra:4.0.7").withConfigurationOverride("cassandra-config");
new CassandraContainer<>("cassandra:4.0.7").withConfigurationOverride("cassandra-config");

@Container
static RabbitMQContainer rabbitMQContainer = new RabbitMQContainer("rabbitmq:3.13-management");
Expand All @@ -44,7 +35,8 @@ static String GetCassandraContactPoint() {

@DynamicPropertySource
static void datasourceProperties(DynamicPropertyRegistry registry) {
registry.add("spring.cassandra.contact-points", ContractsApplicationTests::GetCassandraContactPoint);
registry.add(
"spring.cassandra.contact-points", ContractsApplicationTests::GetCassandraContactPoint);

registry.add("spring.rabbitmq.host", rabbitMQContainer::getHost);
registry.add("spring.rabbitmq.port", rabbitMQContainer::getFirstMappedPort);
Expand All @@ -56,14 +48,10 @@ static void datasourceProperties(DynamicPropertyRegistry registry) {
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;
@Autowired AmqpTemplate template;
@Autowired ContractRepository contractRepository;
@Autowired ContractMilestoneRepository contractMilestoneRepository;
@Autowired TerminationRequestRepository terminationRequestRepository;

@BeforeEach
void clearAll() {
Expand All @@ -72,7 +60,6 @@ void clearAll() {
terminationRequestRepository.deleteAll();
}


/**
* Creates a job request.
*
Expand All @@ -81,27 +68,28 @@ void clearAll() {
@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"));
// 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"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

@TestConfiguration
public class TestConfigBase {
@Bean
public Queue contractsQueueMock() {
return new Queue(ServiceQueueNames.CONTRACTS);
}
@Bean
public Queue contractsQueueMock() {
return new Queue(ServiceQueueNames.CONTRACTS);
}
}

0 comments on commit d0cfc94

Please sign in to comment.