Skip to content

Commit

Permalink
Upgrade to junit 5 #74
Browse files Browse the repository at this point in the history
  • Loading branch information
Piotr Kulasek-Szwed committed Nov 17, 2019
1 parent 3febc98 commit f8c1912
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 23 deletions.
7 changes: 1 addition & 6 deletions src/mokka/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
Expand All @@ -171,12 +172,6 @@
<version>3.3.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock</artifactId>
<version>2.25.1</version>
<scope>test</scope>
</dependency>
</dependencies>

<!--
Expand Down
7 changes: 0 additions & 7 deletions src/mokka/src/main/java/pl/hycom/mokka/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,13 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.envers.repository.support.EnversRevisionRepositoryFactoryBean;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;

/**
* Main class for spring-boot mokka ui application
*
* @author Michal Adamczyk, HYCOM S.A.
*/
@SpringBootApplication
@EnableJpaRepositories(repositoryFactoryBeanClass = EnversRevisionRepositoryFactoryBean.class)
@EnableAsync
@EnableScheduling
public class Application {

public static void main(String[] args) {
Expand Down
12 changes: 12 additions & 0 deletions src/mokka/src/main/java/pl/hycom/mokka/AsyncConfiguration.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package pl.hycom.mokka;

import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;

/**
* @author Piotr Kulasek-Szwed <[email protected]>
*/
@Configuration
@EnableAsync
public class AsyncConfiguration {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package pl.hycom.mokka;

import org.springframework.context.annotation.Configuration;
import org.springframework.data.envers.repository.support.EnversRevisionRepositoryFactoryBean;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;

/**
* @author Piotr Kulasek-Szwed <[email protected]>
*/
@Configuration
@EnableJpaRepositories(
repositoryFactoryBeanClass = EnversRevisionRepositoryFactoryBean.class
)
public class RepositoryConfiguration {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package pl.hycom.mokka;

import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;

/**
* @author Piotr Kulasek-Szwed <[email protected]>
*/
@Configuration
@EnableScheduling
public class SchedulingConfiguration {
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@
import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.TemplateException;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.apache.tomcat.util.codec.binary.Base64;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import pl.hycom.mokka.service.payment.constant.BlueMediaConstants;
import pl.hycom.mokka.service.payment.pojo.BlueMediaPayment;
import pl.hycom.mokka.util.validation.DefaultHashGenerator;
import pl.hycom.mokka.util.validation.HashAlgorithm;
import pl.hycom.mokka.util.validation.HashGenerator;

Expand All @@ -36,11 +39,20 @@
public class DefaultPaymentStatusService implements PaymentStatusService {

private static final String DATE_FORMAT = "yyyyMMddHHmmss";
@Resource

private final RestTemplate restTemplate;

@Setter
private HashGenerator hashGenerator;

@Value("${paymentSchema}")
private String paymentSchema;


public DefaultPaymentStatusService(RestTemplateBuilder builder) {
restTemplate = builder.build();
hashGenerator = new DefaultHashGenerator();
}
/**
* Generates rest post request with SUCCESS status
* @param blueMediaPayment BlueMediaPayment model
Expand Down Expand Up @@ -84,7 +96,6 @@ private void updatePaymentStatus(String status, BlueMediaPayment blueMediaPaymen
String base64String=new String(bytesEncoded);
log.info("Request transformed to Base64:["+base64String+"]");
params.add(BlueMediaConstants.TRANSACTIONS, base64String);
RestTemplate restTemplate = new RestTemplate();
ResponseEntity<String> response = restTemplate.postForEntity(blueMediaPayment.getNotificationURL() , params, String.class);
log.info("Response status: [{}]", response.getStatusCode());
log.info("Response body: [{}]", response.getBody());
Expand Down
4 changes: 2 additions & 2 deletions src/mokka/src/test/java/pl/hycom/mokka/AbstractTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit.jupiter.SpringExtension;

/**
* @author Mariusz Krysztofowicz ([email protected])
*/
@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = Application.class)
@AutoConfigureTestDatabase
@TestPropertySource(locations = "classpath:test.properties")
@ActiveProfiles("test")
public abstract class AbstractTest {

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;

import pl.hycom.mokka.AbstractTest;

import static io.restassured.RestAssured.expect;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.client.RestClientTest;
import org.springframework.http.MediaType;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.web.client.MockRestServiceServer;
import pl.hycom.mokka.service.payment.DefaultPaymentStatusService;
import pl.hycom.mokka.service.payment.pojo.BlueMediaPayment;
Expand All @@ -16,18 +19,19 @@
/**
* @author Mariusz Krysztofowicz ([email protected])
*/
@Disabled
@RestClientTest(DefaultPaymentStatusService.class)
@ActiveProfiles("test")
public class DefaultPaymentStatusServiceTest{

@Autowired
private DefaultPaymentStatusService defaultPaymentStatusService;

@Autowired
private MockRestServiceServer server;

@BeforeEach
public void init() {
defaultPaymentStatusService = new DefaultPaymentStatusService();//new DefaultHashGenerator());
this.server.expect(requestTo("/soap/webservice-http/payment"))
this.server.expect(requestTo("http://localhost:48080/soap/webservice-http/payment"))
.andRespond(withSuccess("OK", MediaType.TEXT_PLAIN));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package pl.hycom.mokka.ui.payment;

import com.github.tomakehurst.wiremock.junit.WireMockRule;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
Expand All @@ -12,7 +11,6 @@

import javax.annotation.Resource;

import static com.github.tomakehurst.wiremock.client.WireMock.*;

/**
* @author Jakub Muras <[email protected]>
Expand Down

0 comments on commit f8c1912

Please sign in to comment.