Skip to content

Commit 227f752

Browse files
committed
Refactor as an addon
1 parent c663c72 commit 227f752

38 files changed

+2081
-2
lines changed

.gitignore

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Eclipse
2+
.classpath
3+
.project
4+
.settings/
5+
6+
# Intellij
7+
.idea/
8+
*.iml
9+
10+
# Maven
11+
target/
12+
pom.xml.tag
13+
pom.xml.releaseBackup
14+
pom.xml.versionsBackup
15+
pom.xml.next
16+
release.properties
17+
18+
#Vim
19+
*~

.travis.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Use docker-based infrastructure
2+
sudo: false
3+
4+
language: java
5+
6+
jdk:
7+
- oraclejdk8
8+
9+
cache:
10+
directories:
11+
- "$HOME/.m2/repository"
12+
13+
install: /bin/true
14+
15+
script:
16+
- mvn -q -B -U -Pstaging,javadoc,compatibility install jacoco:report
17+
- mvn -q -B coveralls:report -DrepoToken=$COVERALLS_TOKEN
18+
19+
after_success:
20+
- echo "<settings><servers><server><id>sonatype-nexus-snapshots</id><username>\${env.SONATYPE_USER}</username><password>\${env.SONATYPE_PASS}</password></server></servers></settings>" > ~/settings.xml
21+
- "[[ $TRAVIS_PULL_REQUEST == \"false\" && $TRAVIS_BRANCH == \"master\" ]] && mvn -q deploy --settings ~/settings.xml -DskipTests=true -Pjavadoc"

AUTHORS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# This source code refers to The SeedStack authors for copyright purposes.
2+
# The master list of authors is in the SeedStack meta repository,
3+
# visible at https://github.com/seedstack/seedstack/blob/master/AUTHORS.

CONTRIBUTORS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# This source code was written by the SeedStack contributors.
2+
# The master list of contributors is in the SeedStack meta repository,
3+
# visible at https://github.com/seedstack/seedstack/blob/master/CONTRIBUTORS.

LICENSE

Lines changed: 373 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
1-
# validation-addon
2-
Bean validation 1.1 (JSR 303 &amp; 349) official integration for SeedStack.
1+
# SeedStack validation add-on
2+
3+
[![Build status](https://travis-ci.org/seedstack/validation-addon.svg?branch=master)](https://travis-ci.org/seedstack/validation-addon) [![Coverage Status](https://coveralls.io/repos/seedstack/validation-addon/badge.svg?branch=master)](https://coveralls.io/r/seedstack/validation-addon?branch=master) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.seedstack/seed-validation/badge.svg?style=flat)](https://maven-badges.herokuapp.com/maven-central/org.seedstack/seed-validation)
4+
5+
Official validation integration for SeedStack.
6+
7+
# Copyright and license
8+
9+
This source code is copyrighted by [The SeedStack Authors](https://github.com/seedstack/seedstack/blob/master/AUTHORS) and
10+
released under the terms of the [Mozilla Public License 2.0](https://www.mozilla.org/MPL/2.0/).

pom.xml

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
<!--
2+
3+
Copyright (c) 2013-2015 by The SeedStack authors. All rights reserved.
4+
5+
This file is part of SeedStack, An enterprise-oriented full development stack.
6+
7+
This Source Code Form is subject to the terms of the Mozilla Public
8+
License, v. 2.0. If a copy of the MPL was not distributed with this
9+
file, You can obtain one at http://mozilla.org/MPL/2.0/.
10+
11+
-->
12+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
13+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
14+
<modelVersion>4.0.0</modelVersion>
15+
16+
<parent>
17+
<groupId>org.seedstack</groupId>
18+
<artifactId>parent</artifactId>
19+
<version>2.0.1-SNAPSHOT</version>
20+
</parent>
21+
22+
<artifactId>seed-validation</artifactId>
23+
<version>2.0.1-SNAPSHOT</version>
24+
25+
<properties>
26+
<seed.version>2.0.0</seed.version>
27+
<hibernate-validator.version>5.1.3.Final</hibernate-validator.version>
28+
29+
<compatibility.groupId>org.seedstack.seed</compatibility.groupId>
30+
<compatibility.artifactId>seed-validation-support</compatibility.artifactId>
31+
<compatibility.version>2.0.0</compatibility.version>
32+
</properties>
33+
34+
<build>
35+
<pluginManagement>
36+
<plugins>
37+
<plugin>
38+
<groupId>org.codehaus.mojo</groupId>
39+
<artifactId>license-maven-plugin</artifactId>
40+
<configuration>
41+
<includedLicenses>
42+
<includedLicense>Apache 2</includedLicense>
43+
<includedLicense>BSD</includedLicense>
44+
<includedLicense>EPL 1.0</includedLicense>
45+
<includedLicense>LGPL 2.1</includedLicense>
46+
<includedLicense>LGPL 3.0</includedLicense>
47+
<includedLicense>MIT License</includedLicense>
48+
<includedLicense>MPL 2.0</includedLicense>
49+
<includedLicense>The JSON License</includedLicense>
50+
<includedLicense>Public Domain</includedLicense>
51+
<includedLicense>WTFPL</includedLicense>
52+
53+
<!-- Some licenses are ignored because they are alternatives to acceptable licenses and the plugin doesn't handle alternate licenses -->
54+
<includedLicense>IGNORED_LICENSE</includedLicense>
55+
</includedLicenses>
56+
<licenseMerges>
57+
<licenseMerge>Apache 2|Apache License, Version 2.0</licenseMerge>
58+
<licenseMerge>Apache 2|The Apache Software License, Version 2.0</licenseMerge>
59+
<licenseMerge>Apache 2|Apache License 2.0</licenseMerge>
60+
<licenseMerge>Apache 2|Apache License, version 2.0</licenseMerge>
61+
<licenseMerge>BSD|The New BSD License</licenseMerge>
62+
<licenseMerge>EPL 1.0|Eclipse Public License, Version 1.0</licenseMerge>
63+
<licenseMerge>LGPL 2.1|GNU Lesser General Public License, Version 2.1</licenseMerge>
64+
<licenseMerge>LGPL 3.0|GNU Lesser Public License</licenseMerge>
65+
<licenseMerge>IGNORED_LICENSE|MPL 1.1</licenseMerge>
66+
<licenseMerge>IGNORED_LICENSE|LGPL 2.1</licenseMerge>
67+
</licenseMerges>
68+
</configuration>
69+
</plugin>
70+
</plugins>
71+
</pluginManagement>
72+
</build>
73+
74+
<dependencies>
75+
<dependency>
76+
<groupId>org.seedstack.seed</groupId>
77+
<artifactId>seed-core-support-core</artifactId>
78+
<version>${seed.version}</version>
79+
</dependency>
80+
<dependency>
81+
<groupId>org.hibernate</groupId>
82+
<artifactId>hibernate-validator</artifactId>
83+
<version>${hibernate-validator.version}</version>
84+
<optional>true</optional>
85+
</dependency>
86+
87+
<dependency>
88+
<groupId>org.seedstack.seed</groupId>
89+
<artifactId>seed-integrationtest-support-core</artifactId>
90+
<version>${seed.version}</version>
91+
<scope>test</scope>
92+
</dependency>
93+
<dependency>
94+
<groupId>org.seedstack.seed</groupId>
95+
<artifactId>seed-el-support</artifactId>
96+
<version>${seed.version}</version>
97+
<scope>test</scope>
98+
</dependency>
99+
<dependency>
100+
<groupId>javax.el</groupId>
101+
<artifactId>javax.el-api</artifactId>
102+
<version>2.2.5</version>
103+
<scope>test</scope>
104+
</dependency>
105+
<dependency>
106+
<groupId>ch.qos.logback</groupId>
107+
<artifactId>logback-classic</artifactId>
108+
<version>1.1.3</version>
109+
<scope>test</scope>
110+
</dependency>
111+
</dependencies>
112+
113+
<scm>
114+
<url>https://github.com/seedstack/validation-addon</url>
115+
<connection>scm:git:git://github.com/seedstack/validation-addon.git</connection>
116+
<developerConnection>scm:git:[email protected]:seedstack/validation-addon.git</developerConnection>
117+
<tag>HEAD</tag>
118+
</scm>
119+
120+
<profiles>
121+
<profile>
122+
<id>staging</id>
123+
<repositories>
124+
<repository>
125+
<id>sonatype-nexus-staging</id>
126+
<name>Sonatype Nexus Staging</name>
127+
<url>https://oss.sonatype.org/content/groups/staging</url>
128+
</repository>
129+
</repositories>
130+
<pluginRepositories>
131+
<pluginRepository>
132+
<id>sonatype-nexus-staging</id>
133+
<name>Sonatype Nexus Staging</name>
134+
<url>https://oss.sonatype.org/content/groups/staging</url>
135+
</pluginRepository>
136+
</pluginRepositories>
137+
</profile>
138+
</profiles>
139+
</project>
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/**
2+
* Copyright (c) 2013-2015 by The SeedStack authors. All rights reserved.
3+
*
4+
* This file is part of SeedStack, An enterprise-oriented full development stack.
5+
*
6+
* This Source Code Form is subject to the terms of the Mozilla Public
7+
* License, v. 2.0. If a copy of the MPL was not distributed with this
8+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
9+
*/
10+
package org.seedstack.seed.validation.internal;
11+
12+
import org.seedstack.seed.validation.api.ValidationException;
13+
import org.assertj.core.api.Assertions;
14+
import org.junit.Test;
15+
import org.junit.runner.RunWith;
16+
import org.seedstack.seed.it.SeedITRunner;
17+
import org.seedstack.seed.validation.internal.pojo.*;
18+
19+
import javax.inject.Inject;
20+
21+
@RunWith(SeedITRunner.class)
22+
public class ValidationPluginIT {
23+
24+
@Inject
25+
DummyServiceParamValidation serviceParam;
26+
27+
@Inject
28+
DummyServiceFieldValidationOK serviceField;
29+
30+
@Inject
31+
DummyServiceParamReturnType serviceReturnType;
32+
33+
@Inject
34+
DummyServiceWithoutValidation serviceWithoutValidation;
35+
36+
@Test
37+
public void services_are_well_injected() {
38+
Assertions.assertThat(serviceParam).isNotNull();
39+
Assertions.assertThat(serviceField).isNotNull();
40+
Assertions.assertThat(serviceReturnType).isNotNull();
41+
Assertions.assertThat(serviceWithoutValidation).isNotNull();
42+
}
43+
44+
@Test
45+
public void param_not_null_validations_ok() {
46+
serviceParam.validateNotNullParam("");
47+
}
48+
49+
@Test(expected = ValidationException.class)
50+
public void param_not_null_validations_are_well_intercepted() {
51+
serviceParam.validateNotNullParam(null);
52+
}
53+
54+
@Test
55+
public void param_valid_validations_ok() {
56+
serviceParam.validateValidParam(new Pojo(Pojo.State.VALID));
57+
}
58+
59+
60+
@Test(expected = ValidationException.class)
61+
public void param_valid_validations_are_well_intercepted() {
62+
serviceParam.validateValidParam(new Pojo(Pojo.State.INVALID));
63+
}
64+
65+
@Test
66+
public void not_null_return_validations_ok() {
67+
serviceReturnType.validateNotNullReturn("");
68+
}
69+
70+
@Test(expected = ValidationException.class)
71+
public void not_null_return_validations_are_well_intercepted() {
72+
serviceReturnType.validateNotNullReturn(null);
73+
}
74+
75+
@Test
76+
public void valid_return_validations_ok() {
77+
serviceReturnType.validateValidReturn(Pojo.State.VALID);
78+
}
79+
80+
@Test(expected = ValidationException.class)
81+
public void valid_return_validations_are_well_intercepted() {
82+
serviceReturnType.validateValidReturn(Pojo.State.INVALID);
83+
}
84+
85+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/**
2+
* Copyright (c) 2013-2015 by The SeedStack authors. All rights reserved.
3+
*
4+
* This file is part of SeedStack, An enterprise-oriented full development stack.
5+
*
6+
* This Source Code Form is subject to the terms of the Mozilla Public
7+
* License, v. 2.0. If a copy of the MPL was not distributed with this
8+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
9+
*/
10+
package org.seedstack.seed.validation.internal;
11+
12+
import org.seedstack.seed.validation.api.ValidationException;
13+
import org.seedstack.seed.validation.internal.pojo.DummyServiceFieldValidation;
14+
import org.junit.Test;
15+
import org.junit.runner.RunWith;
16+
import org.seedstack.seed.it.SeedITRunner;
17+
import org.seedstack.seed.it.api.Expect;
18+
19+
import javax.inject.Inject;
20+
21+
import static org.assertj.core.api.Assertions.assertThat;
22+
23+
@RunWith(SeedITRunner.class)
24+
@Expect(ValidationException.class)
25+
public class ValidationPlugin_ValidationErrorIT {
26+
27+
@Inject
28+
DummyServiceFieldValidation serviceField;
29+
30+
@Test
31+
public void trigger() {
32+
assertThat(serviceField).isNull();
33+
}
34+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* Copyright (c) 2013-2015 by The SeedStack authors. All rights reserved.
3+
*
4+
* This file is part of SeedStack, An enterprise-oriented full development stack.
5+
*
6+
* This Source Code Form is subject to the terms of the Mozilla Public
7+
* License, v. 2.0. If a copy of the MPL was not distributed with this
8+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
9+
*/
10+
package org.seedstack.seed.validation.internal;
11+
12+
import org.seedstack.seed.validation.internal.pojo.DummyServiceFieldValidationOK;
13+
import org.assertj.core.api.Assertions;
14+
import org.junit.Test;
15+
import org.junit.runner.RunWith;
16+
import org.seedstack.seed.it.SeedITRunner;
17+
18+
import javax.inject.Inject;
19+
20+
@RunWith(SeedITRunner.class)
21+
public class ValidationPlugin_ValidationOkIT {
22+
23+
@Inject
24+
DummyServiceFieldValidationOK serviceField;
25+
26+
@Test
27+
public void trigger() {
28+
Assertions.assertThat(serviceField).isNotNull();
29+
}
30+
31+
}

0 commit comments

Comments
 (0)