Commit 7dca1bb8 authored by Christian Langmann's avatar Christian Langmann

initial

parent 6d5f4b32
# ------------------------------------------------------------------------------ #
# Java defaults (https://github.com/github/gitignore/blob/master/Java.gitignore) #
# ------------------------------------------------------------------------------ #
*.class
# Package Files #
*.jar
*.war
*.ear
# ------------------------------------------------------------------------------------------- #
# Eclipse-specific (https://github.com/github/gitignore/blob/master/Global/Eclipse.gitignore) #
# ------------------------------------------------------------------------------------------- #
*.pydevproject
.metadata
bin/**
tmp/**
tmp/**/*
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath
# Recommended for Maven based projects
.project
.classpath
# External tool builders
.externalToolBuilders/
# Locally stored "Eclipse launch configurations"
*.launch
# CDT-specific
.cproject
# PDT-specific
.buildpath
# --------------- #
# Studio-specific #
# --------------- #
.studio/
flows/
target/
src/main/api/.repository/
# ------------- #
# Mule-specific #
# ------------- #
.mule
catalog
src/test/resources/scaffolder/
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<mule-project xmlns="http://www.mulesoft.com/tooling/project" runtimeId="org.mule.tooling.server.3.9.2.ee" schemaVersion="5.3.0.0">
<name>testcontainer</name>
<description></description>
<muleExtension name="Assert Object Equals" qualifier="org.mule.tooling.ui.contribution.assert-object-equals.3.5.0"/>
<muleExtension name="DB Server" qualifier="org.mule.tooling.ui.contribution.dbserver.3.4.0"/>
</mule-project>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.codecentric</groupId>
<artifactId>testcontainer</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>mule</packaging>
<name>Mule testcontainer Application</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<mule.version>3.9.2</mule.version>
<mule.tools.version>1.2</mule.tools.version>
<munit.version>1.3.8</munit.version>
<mule.munit.support.version>3.9.1</mule.munit.support.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.mule.tools.maven</groupId>
<artifactId>mule-app-maven-plugin</artifactId>
<version>${mule.tools.version}</version>
<extensions>true</extensions>
<configuration>
<copyToAppsDirectory>true</copyToAppsDirectory>
<inclusions>
<inclusion>
<groupId>com.mulesoft.munit.utils</groupId>
<artifactId>munit-dbserver-module</artifactId>
</inclusion>
</inclusions>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>add-resource</id>
<phase>generate-resources</phase>
<goals>
<goal>add-resource</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>src/main/app/</directory>
</resource>
<resource>
<directory>src/main/api/</directory>
</resource>
<resource>
<directory>mappings/</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.mulesoft.munit.tools</groupId>
<artifactId>munit-maven-plugin</artifactId>
<version>${munit.version}</version>
<executions>
<execution>
<id>test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
<configuration>
<coverage>
<runCoverage>true</runCoverage>
<formats>
<format>html</format>
</formats>
</coverage>
</configuration>
</plugin>
</plugins>
<testResources>
<testResource>
<directory>src/test/munit</directory>
</testResource>
<testResource>
<directory>src/test/resources</directory>
</testResource>
</testResources>
</build>
<!-- Mule Dependencies -->
<dependencies>
<!-- Xml configuration -->
<dependency>
<groupId>com.mulesoft.muleesb</groupId>
<artifactId>mule-core-ee</artifactId>
<version>${mule.version}</version>
<scope>provided</scope>
</dependency>
<!-- Xml configuration -->
<dependency>
<groupId>com.mulesoft.muleesb.modules</groupId>
<artifactId>mule-module-spring-config-ee</artifactId>
<version>${mule.version}</version>
<scope>provided</scope>
</dependency>
<!-- Mule Transports -->
<dependency>
<groupId>org.mule.transports</groupId>
<artifactId>mule-transport-file</artifactId>
<version>${mule.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mule.transports</groupId>
<artifactId>mule-transport-http</artifactId>
<version>${mule.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.mulesoft.muleesb.transports</groupId>
<artifactId>mule-transport-jdbc-ee</artifactId>
<version>${mule.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.mulesoft.muleesb.transports</groupId>
<artifactId>mule-transport-jms-ee</artifactId>
<version>${mule.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mule.transports</groupId>
<artifactId>mule-transport-vm</artifactId>
<version>${mule.version}</version>
<scope>provided</scope>
</dependency>
<!-- Mule Modules -->
<dependency>
<groupId>org.mule.modules</groupId>
<artifactId>mule-module-scripting</artifactId>
<version>${mule.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mule.modules</groupId>
<artifactId>mule-module-xml</artifactId>
<version>${mule.version}</version>
<scope>provided</scope>
</dependency>
<!-- for testing -->
<dependency>
<groupId>org.mule.tests</groupId>
<artifactId>mule-tests-functional</artifactId>
<version>${mule.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mule.modules</groupId>
<artifactId>mule-module-apikit</artifactId>
<version>${mule.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mule.modules</groupId>
<artifactId>mule-module-db</artifactId>
<version>${mule.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.5</version>
</dependency>
<dependency>
<groupId>com.mulesoft.weave</groupId>
<artifactId>mule-plugin-weave</artifactId>
<version>${mule.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mule.modules</groupId>
<artifactId>mule-module-validation</artifactId>
<version>${mule.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mule.modules</groupId>
<artifactId>mule-module-spring-config</artifactId>
<version>${mule.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>de.codecentric.mule.modules</groupId>
<artifactId>assert-object-equals-connector</artifactId>
<version>1.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.13</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.mulesoft.munit</groupId>
<artifactId>mule-munit-support</artifactId>
<version>${mule.munit.support.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.mulesoft.munit</groupId>
<artifactId>munit-runner</artifactId>
<version>${munit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.mulesoft.munit.utils</groupId>
<artifactId>munit-dbserver-module</artifactId>
<version>1.2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.unittesters</groupId>
<artifactId>munit-db-testcontainers-connector</artifactId>
<version>0.0.6-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>postgresql</artifactId>
<version>1.10.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mule.modules</groupId>
<artifactId>mule-module-http</artifactId>
<version>${mule.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>Central</id>
<name>Central</name>
<url>http://repo1.maven.org/maven2/</url>
<layout>default</layout>
</repository>
<repository>
<id>mulesoft-releases</id>
<name>MuleSoft Releases Repository</name>
<url>http://repository.mulesoft.org/releases/</url>
<layout>default</layout>
</repository>
<repository>
<id>sonartype-release</id>
<name>OSS Sonartype Releases Repository</name>
<url>https://oss.sonatype.org/content/repositories/releases</url>
<layout>default</layout>
</repository>
<repository>
<id>sonartype-snapshot</id>
<name>OSS Sonartype Snapshot Repository</name>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<layout>default</layout>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>mulesoft-release</id>
<name>mulesoft release repository</name>
<layout>default</layout>
<url>http://repository.mulesoft.org/releases/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</project>
#%RAML 1.0
baseUri: http://localhost:8081/
version: v1
title: Testcontainer Sample API
types:
user: |
{
"type": "object",
"$schema": "http://json-schema.org/draft-03/schema",
"id": "http://jsonschema.net",
"required": true,
"properties": {
"id": {
"type": "string",
"required": false
},
"user": {
"type": "string",
"required": true
},
"firstname": {
"type": "string",
"required": false
},
"name": {
"type": "string",
"required": true
}
}
}
/users:
get:
responses:
200:
body:
application/json:
example: |
[
{
"id": "1234",
"name": "Langmann",
"firstname": "Christian",
"user": "clangmann"
},
{
"id": "1235",
"name": "nobody",
"user": "nobody"
}
]
/{id}:
get:
responses:
200:
body:
application/json:
example: |
{
"id": "1234",
"name": "Langmann",
"firstname": "Christian",
"user": "clangmann"
}
404:
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:context="http://www.springframework.org/schema/context"
xmlns:db="http://www.mulesoft.org/schema/mule/db"
xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-current.xsd
http://www.mulesoft.org/schema/mule/db http://www.mulesoft.org/schema/mule/db/current/mule-db.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd">
<context:property-placeholder location="api.${stage:prod}.properties" />
<db:generic-config name="Generic_Database_Configuration" url="${db.url}" driverClassName="org.postgresql.Driver" doc:name="Generic Database Configuration"/>
</mule>
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw" xmlns:db="http://www.mulesoft.org/schema/mule/db" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/db http://www.mulesoft.org/schema/mule/db/current/mule-db.xsd
http://www.mulesoft.org/schema/mule/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd">
<sub-flow name="get_users">
<db:select config-ref="Generic_Database_Configuration" doc:name="get all users">
<db:parameterized-query><![CDATA[select id, firstname, lastname, username from users]]></db:parameterized-query>
</db:select>
<dw:transform-message doc:name="create json">
<dw:set-payload><![CDATA[%dw 1.0
%output application/json
---
payload map {
id: $.id,
user: $.username,
name: $.lastname,
(firstname: $.firstname) when $.firstname != ""
}]]></dw:set-payload>
</dw:transform-message>
</sub-flow>
</mule>
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw" xmlns:db="http://www.mulesoft.org/schema/mule/db" xmlns:validation="http://www.mulesoft.org/schema/mule/validation" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/db http://www.mulesoft.org/schema/mule/db/current/mule-db.xsd
http://www.mulesoft.org/schema/mule/validation http://www.mulesoft.org/schema/mule/validation/current/mule-validation.xsd
http://www.mulesoft.org/schema/mule/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd">
<validation:config name="Validation_Configuration" doc:name="Validation Configuration"/>
<sub-flow name="get_users_id">
<db:select config-ref="Generic_Database_Configuration" doc:name="Lookup user by id">
<db:parameterized-query><![CDATA[select id, firstname, lastname, username from users where id = :id]]></db:parameterized-query>
<db:in-param name="id" value="#[flowVars.id]"/>
</db:select>
<validation:is-not-empty config-ref="Validation_Configuration" message="No user found" exceptionClass="org.mule.module.apikit.exception.NotFoundException" value="#[payload]" doc:name="user found"/>
<dw:transform-message doc:name="extract json user">
<dw:set-payload><![CDATA[%dw 1.0
%output application/json
---
{
id: payload[0].id,
user: payload[0].username,
name: payload[0].lastname,
(firstname: payload[0].firstname) when payload[0].firstname != ""
}]]></dw:set-payload>
</dw:transform-message>
</sub-flow>
</mule>
#Fri Feb 08 15:15:27 CET 2019
encoding=UTF-8
domain=default
redeployment.enabled=true
config.resources=config.xml,testcontainer.xml,get_users.xml,get_users_id.xml
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:db="http://www.mulesoft.org/schema/mule/db"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:apikit="http://www.mulesoft.org/schema/mule/apikit" xmlns:context="http://www.springframework.org/schema/context" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/db http://www.mulesoft.org/schema/mule/db/current/mule-db.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/apikit http://www.mulesoft.org/schema/mule/apikit/current/mule-apikit.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-current.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
<http:listener-config name="httpListenerConfig" host="0.0.0.0" port="${http.port}" doc:name="HTTP Listener Configuration"/>
<apikit:config name="apiConfig" raml="api.raml" consoleEnabled="false" doc:name="Router"/>
<flow name="api-main">
<http:listener config-ref="httpListenerConfig" path="/api/*" doc:name="HTTP"/>
<apikit:router config-ref="apiConfig" doc:name="APIkit Router"/>
<exception-strategy ref="apiKitGlobalExceptionMapping" doc:name="Reference Exception Strategy"/>
</flow>
<flow name="api-console">
<http:listener config-ref="httpListenerConfig" path="/console/*" doc:name="HTTP"/>
<apikit:console config-ref="apiConfig" doc:name="APIkit Console"/>
</flow>
<flow name="get:/users:apiConfig">
<flow-ref name="get_users" doc:name="get users"/>
</flow>
<flow name="get:/users/{id}:apiConfig">
<set-variable variableName="id" value="#[message.inboundProperties['http.uri.params']['id']]" doc:name="id"/>
<flow-ref name="get_users_id" doc:name="get user by id"/>
</flow>
<apikit:mapping-exception-strategy name="apiKitGlobalExceptionMapping">
<apikit:mapping statusCode="404">
<apikit:exception value="org.mule.module.apikit.exception.NotFoundException" />
<set-property propertyName="Content-Type" value="application/json" doc:name="Property"/>
<set-payload value="{ &quot;message&quot;: &quot;Resource not found&quot; }" doc:name="Set Payload"/>
</apikit:mapping>
<apikit:mapping statusCode="405">
<apikit:exception value="org.mule.module.apikit.exception.MethodNotAllowedException" />
<set-property propertyName="Content-Type" value="application/json" doc:name="Property"/>
<set-payload value="{ &quot;message&quot;: &quot;Method not allowed&quot; }" doc:name="Set Payload"/>
</apikit:mapping>
<apikit:mapping statusCode="415">
<apikit:exception value="org.mule.module.apikit.exception.UnsupportedMediaTypeException" />
<set-property propertyName="Content-Type" value="application/json" doc:name="Property"/>
<set-payload value="{ &quot;message&quot;: &quot;Unsupported media type&quot; }" doc:name="Set Payload"/>
</apikit:mapping>
<apikit:mapping statusCode="406">
<apikit:exception value="org.mule.module.apikit.exception.NotAcceptableException" />
<set-property propertyName="Content-Type" value="application/json" doc:name="Property"/>
<set-payload value="{ &quot;message&quot;: &quot;Not acceptable&quot; }" doc:name="Set Payload"/>
</apikit:mapping>
<apikit:mapping statusCode="400">
<apikit:exception value="org.mule.module.apikit.exception.BadRequestException" />
<set-property propertyName="Content-Type" value="application/json" doc:name="Property"/>
<set-payload value="{ &quot;message&quot;: &quot;Bad request&quot; }" doc:name="Set Payload"/>
</apikit:mapping>
</apikit:mapping-exception-strategy>
</mule>
http.port=8081
db.host=localhost
db.port=5432
db.database=mule
db.user=postgres
db.password=mysecretpw
db.url=jdbc:postgresql://${db.host}:${db.port}/${db.database}?user=${db.user}&amp;password=${db.password}
<?xml version="1.0" encoding="utf-8"?>
<Configuration>
<!--These are some of the loggers you can enable.
There are several more you can find in the documentation.
Besides this log4j configuration, you can also use Java VM environment variables
to enable other logs like network (-Djavax.net.debug=ssl or all) and
Garbage Collector (-XX:+PrintGC). These will be append to the console, so you will
see them in the mule_ee.log file. -->
<Appenders>
<RollingFile name="file" fileName="${sys:mule.home}${sys:file.separator}logs${sys:file.separator}tescontainer.log"
filePattern="${sys:mule.home}${sys:file.separator}logs${sys:file.separator}tescontainer-%i.log">
<PatternLayout pattern="%d [%t] %-5p %c - %m%n" />
<SizeBasedTriggeringPolicy size="10 MB" />
<DefaultRolloverStrategy max="10"/>
</RollingFile>
</Appenders>
<Loggers>
<!-- Http Logger shows wire traffic on DEBUG -->
<AsyncLogger name="org.mule.module.http.internal.HttpMessageLogger" level="WARN"/>
<!-- JDBC Logger shows queries and parameters values on DEBUG -->
<AsyncLogger name="com.mulesoft.mule.transport.jdbc" level="WARN"/>
<!-- CXF is used heavily by Mule for web services -->
<AsyncLogger name="org.apache.cxf" level="WARN"/>
<!-- Apache Commons tend to make a lot of noise which can clutter the log-->
<AsyncLogger name="org.apache" level="WARN"/>
<!-- Reduce startup noise -->
<AsyncLogger name="org.springframework.beans.factory" level="WARN"/>
<!-- Mule classes -->
<AsyncLogger name="org.mule" level="INFO"/>
<AsyncLogger name="com.mulesoft" level="INFO"/>
<!-- Reduce DM verbosity -->
<AsyncLogger name="org.jetel" level="WARN"/>
<AsyncLogger name="Tracking" level="WARN"/>
<AsyncRoot level="INFO">
<AppenderRef ref="file" />
</AsyncRoot>
</Loggers>
</Configuration>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:dbserver="http://www.mulesoft.org/schema/mule/dbserver"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:assert-object-equals="http://www.mulesoft.org/schema/mule/assert-object-equals"
xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:munit="http://www.mulesoft.org/schema/mule/munit" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:core="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/dbserver http://www.mulesoft.org/schema/mule/dbserver/current/mule-dbserver.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-current.xsd
http://www.mulesoft.org/schema/mule/munit http://www.mulesoft.org/schema/mule/munit/current/mule-munit.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/assert-object-equals http://www.mulesoft.org/schema/mule/assert-object-equals/current/mule-assert-object-equals.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd">
<munit:config name="munit" doc:name="MUnit configuration" mock-connectors="false" mock-inbounds="false"/>
<context:property-placeholder location="api.dbserver.properties" />
<spring:beans>
<spring:import resource="classpath:config.xml"/>
<spring:import resource="classpath:get_users_id.xml"/>
<spring:import resource="classpath:get_users.xml"/>
<spring:import resource="classpath:testcontainer.xml"/>
</spring:beans>
<dbserver:config name="DB_Server" database="postgres" connectionStringParameters="MODE=PostgreSQL" doc:name="DB Server" sqlFile="USERS.sql"/>
<http:request-config name="HTTP-APIKit" host="localhost" port="${http.port}" basePath="/api/" doc:name="HTTP Request Configuration">
<http:raml-api-configuration location="api.raml"/>
</http:request-config>
<munit:before-suite name="dbserverBefore_Suite" description="MUnit Test">
<dbserver:start-db-server config-ref="DB_Server" doc:name="Start DB Server"/>
</munit:before-suite>
<munit:after-suite name="dbserverAfter_Suite" description="Ater suite actions">
<dbserver:stop-db-server config-ref="DB_Server" doc:name="Stop DB Server"/>
</munit:after-suite>
<munit:before-test name="dbserverBefore_Test" description="Before tests actions">
<dbserver:execute config-ref="DB_Server" sql="TRUNCATE TABLE users" doc:name="Trunc users"/>
<dbserver:execute config-ref="DB_Server" sql="INSERT INTO users (id, username, lastname, firstname) VALUES(1234, 'jdoe', 'Doe', 'John')" doc:name="Insert user"/>
</munit:before-test>
<munit:test name="users-id-get:/users/{id}:apiConfigTest" description="Test">
<http:request config-ref="HTTP-APIKit" path="/users/{id}" method="GET" doc:name="HTTP">
<http:request-builder>
<http:uri-param paramName="id" value="1234"/>
</http:request-builder>
</http:request>
<munit:assert-on-equals expectedValue="#[200]" actualValue="#[message.inboundProperties['http.status']]" doc:name="Assert http.status is 200"/>
<assert-object-equals:compare-objects expected-ref="#[getResource('user-expected.json').asStream()]" doc:name="user is returned " />
</munit:test>
<munit:test name="users-id-get:/users/{id}:apiConfigTest-nouser" description="Test apikit-flow with missing user">
<http:request config-ref="HTTP-APIKit" path="/users/{id}" method="GET" doc:name="HTTP">
<http:request-builder>
<http:uri-param paramName="id" value="2"/>
</http:request-builder>
<http:success-status-code-validator values="404"/>
</http:request>
<munit:assert-on-equals expectedValue="#[404]" actualValue="#[message.inboundProperties['http.status']]" doc:name="Assert http.status is 404"/>
</munit:test>
</mule>
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:db="http://www.mulesoft.org/schema/mule/db" xmlns:context="http://www.springframework.org/schema/context"
xmlns:db-testcontainers="http://www.mulesoft.org/schema/mule/db-testcontainers" xmlns:dbserver="http://www.mulesoft.org/schema/mule/dbserver" xmlns:assert-object-equals="http://www.mulesoft.org/schema/mule/assert-object-equals" xmlns:mock="http://www.mulesoft.org/schema/mule/mock" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:munit="http://www.mulesoft.org/schema/mule/munit" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:core="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/db http://www.mulesoft.org/schema/mule/db/current/mule-db.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-current.xsd
http://www.mulesoft.org/schema/mule/munit http://www.mulesoft.org/schema/mule/munit/current/mule-munit.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/mock http://www.mulesoft.org/schema/mule/mock/current/mule-mock.xsd
http://www.mulesoft.org/schema/mule/assert-object-equals http://www.mulesoft.org/schema/mule/assert-object-equals/current/mule-assert-object-equals.xsd
http://www.mulesoft.org/schema/mule/dbserver http://www.mulesoft.org/schema/mule/dbserver/current/mule-dbserver.xsd
http://www.mulesoft.org/schema/mule/db-testcontainers http://www.mulesoft.org/schema/mule/db-testcontainers/current/mule-db-testcontainers.xsd">
<munit:config name="munit" doc:name="MUnit configuration" mock-connectors="false" mock-inbounds="false"/>
<context:property-placeholder location="api.testcontainer-connector.properties" />
<spring:beans>
<spring:import resource="classpath:config.xml"/>
<spring:import resource="classpath:get_users_id.xml"/>
</spring:beans>
<db-testcontainers:config name="DB_TestContainers_Configuration"
url="${db.url}"
username="${db.user}" password="${db.password}"
doc:name="DB TestContainers: Configuration" dbInitScript="USERS.sql"/>
<munit:before-suite name="testcontainerBefore_Suite" description="MUnit Test">
<db-testcontainers:start-db-container config-ref="DB_TestContainers_Configuration" doc:name="DB TestContainers" runInitScript="true"/>
</munit:before-suite>
<munit:after-suite name="testcontainerAfter_Suite" description="Ater suite actions">
<db-testcontainers:stop-db-container config-ref="DB_TestContainers_Configuration" doc:name="DB TestContainers"/>
</munit:after-suite>
<munit:before-test name="testcontainerBefore_Test" description="Before tests actions">
<db:update config-ref="Generic_Database_Configuration" doc:name="Trunc users">
<db:dynamic-query><![CDATA[TRUNCATE TABLE users;]]></db:dynamic-query>
</db:update>
<db:insert config-ref="Generic_Database_Configuration" doc:name="Insert user">
<db:parameterized-query><![CDATA[INSERT INTO users (id, username, lastname, firstname) VALUES(1234, 'jdoe', 'Doe', 'John');]]></db:parameterized-query>
</db:insert>
</munit:before-test>
<munit:test name="get_users_idTest-happy-path" description="Test">
<set-variable variableName="id" value="#[1234]" doc:name="set id"/>
<flow-ref name="get_users_id" doc:name="get_users_id"/>
<assert-object-equals:compare-objects expected-ref="#[getResource('user-expected.json').asStream()]" doc:name="user is returned " />
</munit:test>
<munit:test name="get_users_idTest-user-not-found" description="Expects a NotFoundException" expectException="org.mule.module.apikit.exception.NotFoundException">
<set-variable variableName="id" value="#[2]" doc:name="set id"/>
<flow-ref name="get_users_id" doc:name="get_users_id"/>
</munit:test>
</mule>
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:db="http://www.mulesoft.org/schema/mule/db" xmlns:context="http://www.springframework.org/schema/context"
xmlns:dbserver="http://www.mulesoft.org/schema/mule/dbserver" xmlns:assert-object-equals="http://www.mulesoft.org/schema/mule/assert-object-equals" xmlns:mock="http://www.mulesoft.org/schema/mule/mock" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:munit="http://www.mulesoft.org/schema/mule/munit" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:core="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-current.xsd
http://www.mulesoft.org/schema/mule/munit http://www.mulesoft.org/schema/mule/munit/current/mule-munit.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/mock http://www.mulesoft.org/schema/mule/mock/current/mule-mock.xsd
http://www.mulesoft.org/schema/mule/assert-object-equals http://www.mulesoft.org/schema/mule/assert-object-equals/current/mule-assert-object-equals.xsd
http://www.mulesoft.org/schema/mule/dbserver http://www.mulesoft.org/schema/mule/dbserver/current/mule-dbserver.xsd">
<munit:config name="munit" doc:name="MUnit configuration" mock-connectors="false" mock-inbounds="false"/>
<context:property-placeholder location="api.dbserver.properties" />
<spring:beans>