Fixed some tests and broken dependencies
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -83,7 +83,7 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.amqp</groupId>
|
||||
<artifactId>spring-rabbit</artifactId>
|
||||
<version>2.0.0.M4</version>
|
||||
<version>2.0.0.BUILD-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
|
||||
@@ -43,7 +43,7 @@ dependencies {
|
||||
compile("org.springframework.boot:spring-boot-starter-actuator")
|
||||
|
||||
testCompile 'org.springframework.boot:spring-boot-starter-test'
|
||||
testCompile 'org.springframework.restdocs:spring-restdocs-mockmvc'
|
||||
testCompile 'org.springframework.restdocs:spring-restdocs-webtestclient'
|
||||
testCompile 'org.springframework.cloud:spring-cloud-contract-wiremock'
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ buildscript {
|
||||
maven { url "http://repo.spring.io/release" }
|
||||
}
|
||||
dependencies {
|
||||
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.0.0.M3")
|
||||
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.0.0.BUILD-SNAPSHOT")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,4 +149,4 @@ configure(project(':loanApplicationService')) {
|
||||
|
||||
wrapper {
|
||||
gradleVersion '3.5'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ buildscript {
|
||||
maven { url "http://repo.spring.io/release" }
|
||||
}
|
||||
dependencies {
|
||||
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.0.0.M3")
|
||||
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.0.0.BUILD-SNAPSHOT")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ buildscript {
|
||||
maven { url "http://repo.spring.io/release" }
|
||||
}
|
||||
dependencies {
|
||||
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.0.0.M3")
|
||||
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.0.0.BUILD-SNAPSHOT")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ buildscript {
|
||||
maven { url "http://repo.spring.io/release" }
|
||||
}
|
||||
dependencies {
|
||||
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.0.0.M3")
|
||||
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.0.0.BUILD-SNAPSHOT")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,28 +65,24 @@ configure([project(':fraudDetectionService'), project(':loanApplicationService')
|
||||
apply plugin: 'io.spring.dependency-management'
|
||||
apply plugin: 'maven-publish'
|
||||
|
||||
ext['jetty.version'] = '9.2.17.v20160517'
|
||||
|
||||
jar {
|
||||
version = '0.0.1'
|
||||
}
|
||||
|
||||
bootJar {
|
||||
enabled = false
|
||||
}
|
||||
|
||||
configurations {
|
||||
compile.exclude module: "spring-boot-starter-tomcat"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile('org.glassfish.jersey.containers:jersey-container-jetty-http:2.23.2') {
|
||||
exclude group: 'org.eclipse.jetty'
|
||||
}
|
||||
compile 'org.springframework.boot:spring-boot-starter-jersey'
|
||||
compile 'org.springframework.boot:spring-boot-starter-jetty'
|
||||
|
||||
testRuntime "org.spockframework:spock-spring:$spockVersion"
|
||||
|
||||
compile('org.glassfish.jersey.connectors:jersey-apache-connector:2.23.2') {
|
||||
exclude group: 'org.eclipse.jetty'
|
||||
}
|
||||
testCompile "org.mockito:mockito-core"
|
||||
testCompile "org.springframework:spring-test"
|
||||
testCompile "org.springframework.boot:spring-boot-test"
|
||||
@@ -118,7 +114,6 @@ configure(project(':fraudDetectionService')) {
|
||||
contractsDir = file("mappings")
|
||||
stubsOutputDirRoot = file("${project.buildDir}/production/${project.name}-stubs/")
|
||||
}
|
||||
ext['jetty.version'] = '9.2.17.v20160517'
|
||||
|
||||
contracts {
|
||||
stubsMode = "REMOTE"
|
||||
@@ -149,5 +144,5 @@ configure(project(':loanApplicationService')) {
|
||||
}
|
||||
|
||||
wrapper {
|
||||
gradleVersion '3.5'
|
||||
gradleVersion '4.0.2'
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
server.port=0
|
||||
@@ -1,24 +0,0 @@
|
||||
package org.springframework.cloud.frauddetection;
|
||||
|
||||
import org.glassfish.jersey.server.ResourceConfig;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@EnableAutoConfiguration
|
||||
@ComponentScan
|
||||
public class Application {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(Application.class, args);
|
||||
}
|
||||
|
||||
@Bean
|
||||
ResourceConfig resourceConfig() {
|
||||
return ResourceConfig.forApplication(new FraudRestApplication());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package org.springframework.cloud.frauddetection;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
public class FraudRestApplication extends javax.ws.rs.core.Application {
|
||||
|
||||
@Override
|
||||
public Set<Class<?>> getClasses() {
|
||||
return Collections.<Class<?>>singleton(FraudDetectionController.class);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Copyright 2013-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* Licensed under the Apache License, Version 2.0 (the "License")
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
@@ -15,22 +15,21 @@
|
||||
*/
|
||||
|
||||
package org.springframework.cloud
|
||||
import org.springframework.cloud.frauddetection.Application
|
||||
import org.springframework.cloud.frauddetection.FraudRestApplication
|
||||
import org.eclipse.jetty.server.Server
|
||||
import org.glassfish.jersey.apache.connector.ApacheConnectorProvider
|
||||
import org.glassfish.jersey.client.ClientConfig
|
||||
import org.glassfish.jersey.jetty.JettyHttpContainerFactory
|
||||
import org.glassfish.jersey.server.ResourceConfig
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext
|
||||
import spock.lang.Shared
|
||||
import spock.lang.Specification
|
||||
|
||||
import javax.ws.rs.client.Client
|
||||
import javax.ws.rs.client.ClientBuilder
|
||||
import javax.ws.rs.client.WebTarget
|
||||
import javax.ws.rs.core.UriBuilder
|
||||
|
||||
import org.eclipse.jetty.server.Server
|
||||
import org.eclipse.jetty.servlet.ServletContextHandler
|
||||
import org.eclipse.jetty.servlet.ServletHolder
|
||||
import org.glassfish.jersey.client.ClientConfig
|
||||
import spock.lang.Shared
|
||||
import spock.lang.Specification
|
||||
|
||||
import org.springframework.cloud.frauddetection.FraudDetectionController
|
||||
|
||||
import static org.springframework.util.SocketUtils.findAvailableTcpPort
|
||||
|
||||
abstract class MvcSpec extends Specification {
|
||||
@@ -45,21 +44,24 @@ abstract class MvcSpec extends Specification {
|
||||
private Client client
|
||||
|
||||
def setupSpec() {
|
||||
|
||||
URI baseUri = UriBuilder.fromUri("http://localhost").port(findAvailableTcpPort(8000)).build()
|
||||
|
||||
|
||||
ResourceConfig resourceConfig = ResourceConfig.forApplication(new FraudRestApplication())
|
||||
resourceConfig.property("contextConfig", new AnnotationConfigApplicationContext(Application))
|
||||
server = JettyHttpContainerFactory.createServer(baseUri, resourceConfig, true)
|
||||
|
||||
ClientConfig clientConfig = new ClientConfig()
|
||||
clientConfig.connectorProvider(new ApacheConnectorProvider())
|
||||
client = ClientBuilder.newClient(clientConfig)
|
||||
|
||||
webTarget = client.target(baseUri)
|
||||
|
||||
int port = findAvailableTcpPort(8000)
|
||||
URI baseUri = UriBuilder.fromUri("http://localhost").port(port).build()
|
||||
// Create Server
|
||||
Server server = new Server(port)
|
||||
// Configure ServletContextHandler
|
||||
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS)
|
||||
context.setContextPath("/")
|
||||
server.setHandler(context)
|
||||
// Create Servlet Container
|
||||
ServletHolder jerseyServlet = context.addServlet(org.glassfish.jersey.servlet.ServletContainer.class, "/*")
|
||||
jerseyServlet.setInitOrder(0)
|
||||
// Tells the Jersey Servlet which REST service/class to load.
|
||||
jerseyServlet.setInitParameter("jersey.config.server.provider.classnames", FraudDetectionController.class.getCanonicalName())
|
||||
// Start the server
|
||||
server.start()
|
||||
ClientConfig clientConfig = new ClientConfig()
|
||||
client = ClientBuilder.newClient(clientConfig)
|
||||
webTarget = client.target(baseUri)
|
||||
}
|
||||
|
||||
def cleanupSpec() {
|
||||
|
||||
@@ -1,21 +1,18 @@
|
||||
package org.springframework.cloud;
|
||||
|
||||
import org.springframework.cloud.frauddetection.Application;
|
||||
import org.springframework.cloud.frauddetection.FraudRestApplication;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.glassfish.jersey.apache.connector.ApacheConnectorProvider;
|
||||
import org.glassfish.jersey.client.ClientConfig;
|
||||
import org.glassfish.jersey.jetty.JettyHttpContainerFactory;
|
||||
import org.glassfish.jersey.server.ResourceConfig;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
|
||||
import java.net.URI;
|
||||
import javax.ws.rs.client.Client;
|
||||
import javax.ws.rs.client.ClientBuilder;
|
||||
import javax.ws.rs.client.WebTarget;
|
||||
import javax.ws.rs.core.UriBuilder;
|
||||
import java.net.URI;
|
||||
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.servlet.ServletContextHandler;
|
||||
import org.eclipse.jetty.servlet.ServletHolder;
|
||||
import org.glassfish.jersey.client.ClientConfig;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.springframework.cloud.frauddetection.FraudDetectionController;
|
||||
|
||||
import static org.springframework.util.SocketUtils.findAvailableTcpPort;
|
||||
|
||||
@@ -24,25 +21,28 @@ public abstract class MvcTest {
|
||||
public static WebTarget webTarget;
|
||||
|
||||
private static Server server;
|
||||
|
||||
private static Client client;
|
||||
|
||||
@BeforeClass
|
||||
public static void setupTest() {
|
||||
|
||||
URI baseUri = UriBuilder.fromUri("http://localhost").port(findAvailableTcpPort(8000)).build();
|
||||
|
||||
|
||||
ResourceConfig resourceConfig = ResourceConfig.forApplication(new FraudRestApplication());
|
||||
resourceConfig.property("contextConfig", new AnnotationConfigApplicationContext(Application.class));
|
||||
server = JettyHttpContainerFactory.createServer(baseUri, resourceConfig, true);
|
||||
|
||||
public static void setupTest() throws Exception {
|
||||
int port = findAvailableTcpPort(8000);
|
||||
URI baseUri = UriBuilder.fromUri("http://localhost").port(port).build();
|
||||
// Create Server
|
||||
Server server = new Server(port);
|
||||
// Configure ServletContextHandler
|
||||
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
|
||||
context.setContextPath("/");
|
||||
server.setHandler(context);
|
||||
// Create Servlet Container
|
||||
ServletHolder jerseyServlet = context.addServlet(org.glassfish.jersey.servlet.ServletContainer.class, "/*");
|
||||
jerseyServlet.setInitOrder(0);
|
||||
// Tells the Jersey Servlet which REST service/class to load.
|
||||
jerseyServlet.setInitParameter("jersey.config.server.provider.classnames", FraudDetectionController.class.getCanonicalName());
|
||||
// Start the server
|
||||
server.start();
|
||||
ClientConfig clientConfig = new ClientConfig();
|
||||
clientConfig.connectorProvider(new ApacheConnectorProvider());
|
||||
client = ClientBuilder.newClient(clientConfig);
|
||||
|
||||
webTarget = client.target(baseUri);
|
||||
|
||||
try {
|
||||
server.start();
|
||||
} catch (Exception e) {
|
||||
|
||||
Binary file not shown.
@@ -1,6 +1,6 @@
|
||||
#Fri Apr 28 10:55:26 CEST 2017
|
||||
#Mon Jul 31 11:13:36 CEST 2017
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0.2-bin.zip
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"id" : "856bd753-2488-4549-b84f-512e851958a9",
|
||||
"request" : {
|
||||
"url" : "/fraudcheck",
|
||||
"method" : "PUT",
|
||||
"headers" : {
|
||||
"Content-Type" : {
|
||||
"equalTo" : "application/vnd.fraud.v1+json"
|
||||
}
|
||||
},
|
||||
"bodyPatterns" : [ {
|
||||
"matchesJsonPath" : "$[?(@.['loanAmount'] == 99999)]"
|
||||
}, {
|
||||
"matchesJsonPath" : "$[?(@.['clientPesel'] =~ /[0-9]{10}/)]"
|
||||
} ]
|
||||
},
|
||||
"response" : {
|
||||
"status" : 200,
|
||||
"body" : "{\"fraudCheckStatus\":\"FRAUD\",\"rejectionReason\":\"Amount too high\"}",
|
||||
"headers" : {
|
||||
"Content-Type" : "application/vnd.fraud.v1+json"
|
||||
},
|
||||
"transformers" : [ "response-template" ]
|
||||
},
|
||||
"uuid" : "856bd753-2488-4549-b84f-512e851958a9"
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"id" : "263aac46-1534-497d-9cc6-114a29ffa0de",
|
||||
"request" : {
|
||||
"url" : "/fraudcheck",
|
||||
"method" : "PUT",
|
||||
"headers" : {
|
||||
"Content-Type" : {
|
||||
"equalTo" : "application/vnd.fraud.v1+json"
|
||||
}
|
||||
},
|
||||
"bodyPatterns" : [ {
|
||||
"matchesJsonPath" : "$[?(@.['loanAmount'] == 123.123)]"
|
||||
}, {
|
||||
"matchesJsonPath" : "$[?(@.['clientPesel'] =~ /[0-9]{10}/)]"
|
||||
} ]
|
||||
},
|
||||
"response" : {
|
||||
"status" : 200,
|
||||
"body" : "{\"fraudCheckStatus\":\"OK\",\"rejectionReason\":null}",
|
||||
"headers" : {
|
||||
"Content-Type" : "application/vnd.fraud.v1+json"
|
||||
},
|
||||
"transformers" : [ "response-template" ]
|
||||
},
|
||||
"uuid" : "263aac46-1534-497d-9cc6-114a29ffa0de"
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
{
|
||||
"request": {
|
||||
"method": "PUT",
|
||||
"headers": {
|
||||
"Content-Type": {
|
||||
"equalTo": "application/vnd.fraud.v1+json"
|
||||
}
|
||||
},
|
||||
"url": "/fraudcheck",
|
||||
"bodyPatterns": [
|
||||
{
|
||||
"matches": "\\s*\\{\\s*\"clientPesel\"\\s*:\\s*\"?[0-9]{10}\"?\\s*,\\s*\"loanAmount\"\\s*:\\s*\"?99999\"?\\s*\\}\\s*"
|
||||
}
|
||||
]
|
||||
},
|
||||
"response": {
|
||||
"status": 200,
|
||||
"headers": {
|
||||
"Content-Type": "application/vnd.fraud.v1+json"
|
||||
},
|
||||
"body": "{\"fraudCheckStatus\":\"FRAUD\",\"rejectionReason\":\"Amount too high\"}"
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
{
|
||||
"request": {
|
||||
"method": "PUT",
|
||||
"headers": {
|
||||
"Content-Type": {
|
||||
"equalTo": "application/vnd.fraud.v1+json"
|
||||
}
|
||||
},
|
||||
"url": "/fraudcheck",
|
||||
"bodyPatterns": [
|
||||
{
|
||||
"matches": "\\s*\\{\\s*\"clientPesel\"\\s*:\\s*\"?[0-9]{10}\"?\\s*,\\s*\"loanAmount\"\\s*:\\s*\"?123.123\"?\\s*\\}\\s*"
|
||||
}
|
||||
]
|
||||
},
|
||||
"response": {
|
||||
"status": 200,
|
||||
"headers": {
|
||||
"Content-Type": "application/vnd.fraud.v1+json"
|
||||
},
|
||||
"body": "{\"fraudCheckStatus\":\"OK\",\"rejectionReason\":null}"
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ buildscript {
|
||||
maven { url "http://repo.spring.io/release" }
|
||||
}
|
||||
dependencies {
|
||||
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.0.0.M3")
|
||||
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.0.0.BUILD-SNAPSHOT")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ buildscript {
|
||||
maven { url "http://repo.spring.io/release" }
|
||||
}
|
||||
dependencies {
|
||||
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.0.0.M3")
|
||||
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.0.0.BUILD-SNAPSHOT")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user