Commit efd621d4 authored by Nacho's avatar Nacho
Browse files

Initial commit

parents
Loading
Loading
Loading
Loading

.gitignore

0 → 100644
+4 −0
Original line number Diff line number Diff line
.*
!.gitignore
!.gitlab-ci.yml
target

.gitlab-ci.yml

0 → 100644
+20 −0
Original line number Diff line number Diff line
stages:
  - build

maven-build:
  stage: build
  image: redmic/maven-gitlab
  variables:
    MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"
  only:
    - branches
  cache:
    paths:
      - .m2/repository/
  script:
    - mvn deploy -B
  artifacts:
    name: "$CI_PROJECT_NAME"
    expire_in: '6 months'
    paths:
      - target/*.jar

README.md

0 → 100644
+3 −0
Original line number Diff line number Diff line
[![pipeline status](https://git.redmic.net/redmic-server/test-utils/badges/dev/pipeline.svg)](https://git.redmic.net/redmic-server/test-utils/commits/dev)

TODO

pom.xml

0 → 100644
+119 −0
Original line number Diff line number Diff line
<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/xsd/maven-4.0.0.xsd">

	<parent>
		<groupId>org.springframework.boot</groupId>
   		<artifactId>spring-boot-starter-parent</artifactId>
    	<version>2.0.0.RELEASE</version>
		<relativePath/>
	</parent>

	<modelVersion>4.0.0</modelVersion>
	<groupId>es.redmic.lib</groupId>
	<artifactId>test-utils</artifactId>
	<packaging>jar</packaging>
	<version>0.6.0</version>
	<name>Test utils</name>
	<description>Utilidades y servicios comunes para los tests</description>
	
	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
		<maven.compiler.source>1.8</maven.compiler.source>
		<maven.compiler.target>1.8</maven.compiler.target>
		<java.version>1.8</java.version>

		<!-- REDMIC -->
		<redmic.models.version>0.6.0</redmic.models.version>
		<redmic.utils.version>0.6.0</redmic.utils.version>
		<!-- Others -->
		<oauth.version>2.3.0.RELEASE</oauth.version>
		<jackson-datatype-jts.version>2.4</jackson-datatype-jts.version>
		<ma.glasnost.orika.core>1.5.2</ma.glasnost.orika.core>
		<powermock.version>1.7.3</powermock.version>
		
		<!-- Environment variables -->
		<env.MAVEN_REPO_URL>https://artifactory.redmic.net/artifactory</env.MAVEN_REPO_URL>
	</properties>

	<dependencies>
	
		<dependency>
			<groupId>es.redmic.lib</groupId>
			<artifactId>models</artifactId>
			<version>${redmic.models.version}</version>
		</dependency>
		
		<dependency>
			<groupId>es.redmic.lib</groupId>
			<artifactId>utils</artifactId>
			<version>${redmic.utils.version}</version>
		</dependency>

		<dependency>
			<groupId>org.springframework.security.oauth</groupId>
			<artifactId>spring-security-oauth2</artifactId>
			<version>${oauth.version}</version>
		</dependency>

		<dependency>
			<groupId>com.fasterxml.jackson.core</groupId>
			<artifactId>jackson-databind</artifactId>
		</dependency>

		<dependency>
			<groupId>com.bedatadriven</groupId>
			<artifactId>jackson-datatype-jts</artifactId>
			<version>${jackson-datatype-jts.version}</version>
		</dependency>

		<dependency>
			<groupId>ma.glasnost.orika</groupId>
			<artifactId>orika-core</artifactId>
			<version>${ma.glasnost.orika.core}</version>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
		</dependency>

		<dependency>
			<groupId>org.springframework.security</groupId>
			<artifactId>spring-security-test</artifactId>
		</dependency>

		<dependency>
			<groupId>org.powermock</groupId>
			<artifactId>powermock-api-easymock</artifactId>
			<version>${powermock.version}</version>
		</dependency>

		<dependency>
			<groupId>org.powermock</groupId>
			<artifactId>powermock-module-junit4</artifactId>
			<version>${powermock.version}</version>
		</dependency>
		
		<!--test de documentación -->

		<dependency>
			<groupId>org.springframework.restdocs</groupId>
			<artifactId>spring-restdocs-mockmvc</artifactId>
		</dependency>
	</dependencies>
	<distributionManagement>
		<repository>
			<id>central</id>
			<name>redmic-releases</name>
			<url>${env.MAVEN_REPO_URL}/libs-release-local</url>
		</repository>
		<snapshotRepository>
			<id>snapshots</id>
			<name>redmic-snapshots</name>
			<url>${env.MAVEN_REPO_URL}/libs-snapshot-local</url>
			<uniqueVersion>false</uniqueVersion>
		</snapshotRepository>
	</distributionManagement>
</project>
 No newline at end of file
+48 −0
Original line number Diff line number Diff line
package es.redmic.testutils.documentation;

import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessRequest;
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessResponse;
import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint;

import org.junit.Rule;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.restdocs.JUnitRestDocumentation;
import org.springframework.restdocs.mockmvc.RestDocumentationResultHandler;
import org.springframework.security.web.FilterChainProxy;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.web.context.WebApplicationContext;

import com.fasterxml.jackson.databind.ObjectMapper;

import es.redmic.testutils.oauth.IntegrationTestBase;

@ActiveProfiles("test")
public abstract class DocumentationCommandBaseTest extends IntegrationTestBase {

	@Rule
	public JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation("target/generated-snippets");

	@Autowired
	protected ObjectMapper mapper;

	@Autowired
	protected WebApplicationContext webApplicationContext;

	@Autowired
	protected FilterChainProxy springSecurityFilterChain;

	protected RestDocumentationResultHandler document = document("{class-name}/{method-name}",
			preprocessRequest(prettyPrint()), preprocessResponse(prettyPrint()));

	protected MockMvc mockMvc;

	@Value("${controller.mapping.EDIT_SCHEMA}")
	protected String editSchemaPath;

	protected final String SCHEME = "https";

	protected final Integer PORT = 443;
}