Skip to content

Commit

Permalink
Merge pull request #11 from dekaulitz/addUIntegration
Browse files Browse the repository at this point in the history
Add u integration
  • Loading branch information
dekaulitz authored Feb 23, 2020
2 parents d4ed382 + d743c7c commit 22e56e9
Show file tree
Hide file tree
Showing 35 changed files with 1,669 additions and 909 deletions.
1 change: 0 additions & 1 deletion .env.local
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ export APPLICATION_NAME=mockup
export DATABASE_HOST=mongodb://localhost:27017/mongoDbTest
export SERVER_PORT=8080
export WEB_LOG_LEVEL=info
export LOG_LEVEL=info
9 changes: 9 additions & 0 deletions DockerfileMaven
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM maven:3.6.3-ibmjava-8-alpine AS build
COPY src /home/app/src
COPY pom.xml /home/app
RUN mvn -f /home/app/pom.xml clean package

FROM openjdk:8-alpine
COPY --from=build /home/app/target/mockyup-0.0.1-SNAPSHOT.jar /usr/app/app.jar
EXPOSE 8080
ENTRYPOINT ["java","-jar","/usr/app/app.jar"]
83 changes: 48 additions & 35 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,39 +26,39 @@
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-core</artifactId>
<version>${swagger-core-version}</version>
</dependency>
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-annotations</artifactId>
<version>${swagger-core-version}</version>
</dependency>
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-models</artifactId>
<version>${swagger-core-version}</version>
</dependency>
<!-- swagger-parser v2 -->
<version>2.1.1</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>io.swagger.core.v3</groupId>-->
<!-- <artifactId>swagger-annotations</artifactId>-->
<!-- <version>${swagger-core-version}</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>io.swagger.core.v3</groupId>-->
<!-- <artifactId>swagger-models</artifactId>-->
<!-- <version>${swagger-core-version}</version>-->
<!-- </dependency>-->
<!-- &lt;!&ndash; swagger-parser v2 &ndash;&gt;-->
<dependency>
<groupId>io.swagger.parser.v3</groupId>
<artifactId>swagger-parser</artifactId>
<version>${swagger-parser-version}</version>
</dependency>
<dependency>
<groupId>io.swagger.parser.v3</groupId>
<artifactId>swagger-parser-core</artifactId>
<version>${swagger-parser-version}</version>
</dependency>
<dependency>
<groupId>io.swagger.parser.v3</groupId>
<artifactId>swagger-parser-v3</artifactId>
<version>${swagger-parser-version}</version>
</dependency>
<dependency>
<groupId>io.swagger.parser.v3</groupId>
<artifactId>swagger-parser-v2-converter</artifactId>
<version>${swagger-parser-version}</version>
</dependency>
<version>2.0.17</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>io.swagger.parser.v3</groupId>-->
<!-- <artifactId>swagger-parser-core</artifactId>-->
<!-- <version>${swagger-parser-version}</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>io.swagger.parser.v3</groupId>-->
<!-- <artifactId>swagger-parser-v3</artifactId>-->
<!-- <version>${swagger-parser-version}</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>io.swagger.parser.v3</groupId>-->
<!-- <artifactId>swagger-parser-v2-converter</artifactId>-->
<!-- <version>${swagger-parser-version}</version>-->
<!-- </dependency>-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
Expand Down Expand Up @@ -105,6 +105,10 @@
<artifactId>logback-json-classic</artifactId>
<version>0.1.5</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
Expand All @@ -115,23 +119,32 @@
<artifactId>de.flapdoodle.embed.mongo</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-test</artifactId>
<scope>test</scope>
</dependency>
<!-- <dependency>-->
<!-- <groupId>io.projectreactor</groupId>-->
<!-- <artifactId>reactor-test</artifactId>-->
<!-- <scope>test</scope>-->
<!-- </dependency>-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<scope>compile</scope>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.jetbrains</groupId>-->
<!-- <artifactId>annotations</artifactId>-->
<!-- <version>RELEASE</version>-->
<!-- <scope>compile</scope>-->
<!-- </dependency>-->
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>com.github.dekaulitz.mockyup.MockyupApplication</mainClass>
</configuration>
</plugin>
</plugins>
</build>
Expand Down
6 changes: 2 additions & 4 deletions runner.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/usr/bin/env bash

set +o histexpand
#set variable from args
for i in "$@"; do
case ${i} in
Expand All @@ -26,7 +24,7 @@ done
CheckFile() {
if [ ! -z "${ENVIRONMENT+x}" ]; then
echo "load configuration from "${ENVIRONMENT}
ENVIRONMENT=".env."${ENVIRONMENT}
ENVIRONMENT=${ENVIRONMENT}
else
echo "-env or --environment argument not available, we use default variable value 'dev' for now!!"
ENVIRONMENT=".env.dev"
Expand All @@ -40,8 +38,8 @@ RunningAsJar() {
exit
}
BuildImageDocker() {
mvn install
if [ -z "${DOCKERFILE+x}" ]; then
mvn install
docker build -t $APPLICATION_NAME:latest .
else
docker build -t ${APPLICATION_NAME}:latest -f ${DOCKERFILE} .
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ public void addCorsMappings(CorsRegistry registry) {

@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/docs-swagger/**").addResourceLocations(
registry.addResourceHandler("/mocks/docs-swagger/**").addResourceLocations(
"classpath:/public/");
registry.addResourceHandler("/mocks/static/**").addResourceLocations(
"classpath:templates/dist");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

import com.fasterxml.jackson.core.JsonProcessingException;
import com.github.dekaulitz.mockyup.utils.JsonMapper;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
public class LogsMapper {

public static String logRequest(Map<String, Object> requestHeaders) {
public String logRequest(Map<String, Object> requestHeaders) {
try {
return JsonMapper.mapper().writeValueAsString(requestHeaders);
} catch (JsonProcessingException e) {
Expand All @@ -16,4 +18,14 @@ public static String logRequest(Map<String, Object> requestHeaders) {
}

}

public String logRequest(Object object) {
try {
return JsonMapper.mapper().writeValueAsString(object);
} catch (JsonProcessingException e) {
e.printStackTrace();
return null;
}

}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
package com.github.dekaulitz.mockyup.controllers;

import com.github.dekaulitz.mockyup.configuration.logs.LogsMapper;
import com.github.dekaulitz.mockyup.models.helper.MockExample;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

public class BaseController {
protected final LogsMapper logsMapper;
protected Logger log = LoggerFactory.getLogger(this.getClass());

public BaseController(LogsMapper logsMapper) {
this.logsMapper = logsMapper;
}

/**
* @param mock
* @return
Expand All @@ -17,4 +23,5 @@ public class BaseController {
protected ResponseEntity<Object> generateMockResponseEntity(MockExample mock) {
return new ResponseEntity<>(mock.getResponse().getResponse(), HttpStatus.valueOf(mock.getResponse().getHttpCode()));
}

}
Loading

0 comments on commit 22e56e9

Please sign in to comment.