Merge pull request #1 from myrle-krantz/develop
adding example for api domain object testing.
diff --git a/api/build.gradle b/api/build.gradle
index c5b6745..17c6648 100644
--- a/api/build.gradle
+++ b/api/build.gradle
@@ -21,6 +21,10 @@
[group: 'org.hibernate', name: 'hibernate-validator', version: versions.validator],
[group: 'org.hibernate', name: 'hibernate-validator-annotation-processor', version: versions.validator]
)
+
+ testCompile(
+ [group: 'io.mifos.core', name: 'test', version: versions.frameworktest],
+ )
}
publishing {
diff --git a/api/src/main/java/io/mifos/template/api/v1/EventConstants.java b/api/src/main/java/io/mifos/template/api/v1/EventConstants.java
index ec508b0..69b1343 100644
--- a/api/src/main/java/io/mifos/template/api/v1/EventConstants.java
+++ b/api/src/main/java/io/mifos/template/api/v1/EventConstants.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 The Mifos Initiative
+ * Copyright 2017 The Mifos Initiative.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/api/src/main/java/io/mifos/template/api/v1/PermittableGroupIds.java b/api/src/main/java/io/mifos/template/api/v1/PermittableGroupIds.java
index 2a3bdb1..239e2ac 100644
--- a/api/src/main/java/io/mifos/template/api/v1/PermittableGroupIds.java
+++ b/api/src/main/java/io/mifos/template/api/v1/PermittableGroupIds.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 The Mifos Initiative
+ * Copyright 2017 The Mifos Initiative.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/api/src/main/java/io/mifos/template/api/v1/client/IamATeapotException.java b/api/src/main/java/io/mifos/template/api/v1/client/IamATeapotException.java
index c1c9e74..ec4383c 100644
--- a/api/src/main/java/io/mifos/template/api/v1/client/IamATeapotException.java
+++ b/api/src/main/java/io/mifos/template/api/v1/client/IamATeapotException.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 The Mifos Initiative
+ * Copyright 2017 The Mifos Initiative.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/api/src/main/java/io/mifos/template/api/v1/client/TemplateManager.java b/api/src/main/java/io/mifos/template/api/v1/client/TemplateManager.java
index 6b0cb4c..9914e36 100644
--- a/api/src/main/java/io/mifos/template/api/v1/client/TemplateManager.java
+++ b/api/src/main/java/io/mifos/template/api/v1/client/TemplateManager.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 The Mifos Initiative
+ * Copyright 2017 The Mifos Initiative.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/api/src/main/java/io/mifos/template/api/v1/domain/Sample.java b/api/src/main/java/io/mifos/template/api/v1/domain/Sample.java
index d3dbd54..6f25719 100644
--- a/api/src/main/java/io/mifos/template/api/v1/domain/Sample.java
+++ b/api/src/main/java/io/mifos/template/api/v1/domain/Sample.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 The Mifos Initiative
+ * Copyright 2017 The Mifos Initiative.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/api/src/test/java/io/mifos/template/api/v1/domain/SampleTest.java b/api/src/test/java/io/mifos/template/api/v1/domain/SampleTest.java
new file mode 100644
index 0000000..acf33cb
--- /dev/null
+++ b/api/src/test/java/io/mifos/template/api/v1/domain/SampleTest.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2017 The Mifos Initiative.
+ *
+ * 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.mifos.template.api.v1.domain;
+
+import io.mifos.core.test.domain.ValidationTest;
+import io.mifos.core.test.domain.ValidationTestCase;
+import org.apache.commons.lang.RandomStringUtils;
+import org.junit.runners.Parameterized;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+public class SampleTest extends ValidationTest<Sample> {
+
+ public SampleTest(ValidationTestCase<Sample> testCase) {
+ super(testCase);
+ }
+
+ @Override
+ protected Sample createValidTestSubject() {
+ return Sample.create("xxxx", "yyy");
+ }
+
+ @Parameterized.Parameters
+ public static Collection testCases() {
+ final Collection<ValidationTestCase> ret = new ArrayList<>();
+ ret.add(new ValidationTestCase<Sample>("basicCase")
+ .adjustment(x -> {})
+ .valid(true));
+ ret.add(new ValidationTestCase<Sample>("nullIdentifier")
+ .adjustment(x -> x.setIdentifier(null))
+ .valid(false));
+ ret.add(new ValidationTestCase<Sample>("tooShortIdentifier")
+ .adjustment(x -> x.setIdentifier("z"))
+ .valid(false));
+ ret.add(new ValidationTestCase<Sample>("tooLongPayload")
+ .adjustment(x -> x.setPayload(RandomStringUtils.randomAlphanumeric(513)))
+ .valid(false));
+ return ret;
+ }
+
+}
\ No newline at end of file
diff --git a/component-test/src/main/java/io/mifos/template/TestSample.java b/component-test/src/main/java/io/mifos/template/TestSample.java
index ea40b09..b829355 100644
--- a/component-test/src/main/java/io/mifos/template/TestSample.java
+++ b/component-test/src/main/java/io/mifos/template/TestSample.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 The Mifos Initiative
+ * Copyright 2017 The Mifos Initiative.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/component-test/src/main/java/io/mifos/template/listener/MigrationEventListener.java b/component-test/src/main/java/io/mifos/template/listener/MigrationEventListener.java
index 3f67928..82408bb 100644
--- a/component-test/src/main/java/io/mifos/template/listener/MigrationEventListener.java
+++ b/component-test/src/main/java/io/mifos/template/listener/MigrationEventListener.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 The Mifos Initiative
+ * Copyright 2017 The Mifos Initiative.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/component-test/src/main/java/io/mifos/template/listener/SampleEventListener.java b/component-test/src/main/java/io/mifos/template/listener/SampleEventListener.java
index 6f547a4..2e3c2cb 100644
--- a/component-test/src/main/java/io/mifos/template/listener/SampleEventListener.java
+++ b/component-test/src/main/java/io/mifos/template/listener/SampleEventListener.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 The Mifos Initiative
+ * Copyright 2017 The Mifos Initiative.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/service/src/main/java/io/mifos/template/service/ServiceConstants.java b/service/src/main/java/io/mifos/template/service/ServiceConstants.java
index e9ee910..e9e0623 100644
--- a/service/src/main/java/io/mifos/template/service/ServiceConstants.java
+++ b/service/src/main/java/io/mifos/template/service/ServiceConstants.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 The Mifos Initiative
+ * Copyright 2017 The Mifos Initiative.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/service/src/main/java/io/mifos/template/service/TemplateApplication.java b/service/src/main/java/io/mifos/template/service/TemplateApplication.java
index bd2464b..7ca88f0 100644
--- a/service/src/main/java/io/mifos/template/service/TemplateApplication.java
+++ b/service/src/main/java/io/mifos/template/service/TemplateApplication.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 The Mifos Initiative
+ * Copyright 2017 The Mifos Initiative.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/service/src/main/java/io/mifos/template/service/TemplateConfiguration.java b/service/src/main/java/io/mifos/template/service/TemplateConfiguration.java
index 2b6ce06..d0fd484 100644
--- a/service/src/main/java/io/mifos/template/service/TemplateConfiguration.java
+++ b/service/src/main/java/io/mifos/template/service/TemplateConfiguration.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 The Mifos Initiative
+ * Copyright 2017 The Mifos Initiative.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/service/src/main/java/io/mifos/template/service/internal/command/InitializeServiceCommand.java b/service/src/main/java/io/mifos/template/service/internal/command/InitializeServiceCommand.java
index 5e8dc63..db85b9d 100644
--- a/service/src/main/java/io/mifos/template/service/internal/command/InitializeServiceCommand.java
+++ b/service/src/main/java/io/mifos/template/service/internal/command/InitializeServiceCommand.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 The Mifos Initiative
+ * Copyright 2017 The Mifos Initiative.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/service/src/main/java/io/mifos/template/service/internal/command/SampleCommand.java b/service/src/main/java/io/mifos/template/service/internal/command/SampleCommand.java
index d700762..8ee6d92 100644
--- a/service/src/main/java/io/mifos/template/service/internal/command/SampleCommand.java
+++ b/service/src/main/java/io/mifos/template/service/internal/command/SampleCommand.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 The Mifos Initiative
+ * Copyright 2017 The Mifos Initiative.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/service/src/main/java/io/mifos/template/service/internal/command/handler/MigrationAggregate.java b/service/src/main/java/io/mifos/template/service/internal/command/handler/MigrationAggregate.java
index 6108d06..e4e3de1 100644
--- a/service/src/main/java/io/mifos/template/service/internal/command/handler/MigrationAggregate.java
+++ b/service/src/main/java/io/mifos/template/service/internal/command/handler/MigrationAggregate.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 The Mifos Initiative
+ * Copyright 2017 The Mifos Initiative.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/service/src/main/java/io/mifos/template/service/internal/command/handler/SampleAggregate.java b/service/src/main/java/io/mifos/template/service/internal/command/handler/SampleAggregate.java
index 7109b49..4de453a 100644
--- a/service/src/main/java/io/mifos/template/service/internal/command/handler/SampleAggregate.java
+++ b/service/src/main/java/io/mifos/template/service/internal/command/handler/SampleAggregate.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 The Mifos Initiative
+ * Copyright 2017 The Mifos Initiative.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/service/src/main/java/io/mifos/template/service/internal/mapper/SampleMapper.java b/service/src/main/java/io/mifos/template/service/internal/mapper/SampleMapper.java
index de36734..983b5d5 100644
--- a/service/src/main/java/io/mifos/template/service/internal/mapper/SampleMapper.java
+++ b/service/src/main/java/io/mifos/template/service/internal/mapper/SampleMapper.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 The Mifos Initiative
+ * Copyright 2017 The Mifos Initiative.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/service/src/main/java/io/mifos/template/service/internal/repository/SampleJpaEntity.java b/service/src/main/java/io/mifos/template/service/internal/repository/SampleJpaEntity.java
index c8c741e..9cbcd73 100644
--- a/service/src/main/java/io/mifos/template/service/internal/repository/SampleJpaEntity.java
+++ b/service/src/main/java/io/mifos/template/service/internal/repository/SampleJpaEntity.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 The Mifos Initiative
+ * Copyright 2017 The Mifos Initiative.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/service/src/main/java/io/mifos/template/service/internal/repository/SampleJpaEntityRepository.java b/service/src/main/java/io/mifos/template/service/internal/repository/SampleJpaEntityRepository.java
index 3f5539e..87ea8a7 100644
--- a/service/src/main/java/io/mifos/template/service/internal/repository/SampleJpaEntityRepository.java
+++ b/service/src/main/java/io/mifos/template/service/internal/repository/SampleJpaEntityRepository.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 The Mifos Initiative
+ * Copyright 2017 The Mifos Initiative.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/service/src/main/java/io/mifos/template/service/internal/service/SampleService.java b/service/src/main/java/io/mifos/template/service/internal/service/SampleService.java
index 5b4be95..caba840 100644
--- a/service/src/main/java/io/mifos/template/service/internal/service/SampleService.java
+++ b/service/src/main/java/io/mifos/template/service/internal/service/SampleService.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 The Mifos Initiative
+ * Copyright 2017 The Mifos Initiative.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/service/src/main/java/io/mifos/template/service/rest/SampleRestController.java b/service/src/main/java/io/mifos/template/service/rest/SampleRestController.java
index 9cce47d..9919252 100644
--- a/service/src/main/java/io/mifos/template/service/rest/SampleRestController.java
+++ b/service/src/main/java/io/mifos/template/service/rest/SampleRestController.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 The Mifos Initiative
+ * Copyright 2017 The Mifos Initiative.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/service/src/main/resources/application.yml b/service/src/main/resources/application.yml
index 1859323..8b395ca 100644
--- a/service/src/main/resources/application.yml
+++ b/service/src/main/resources/application.yml
@@ -1,5 +1,5 @@
#
-# Copyright 2017 The Mifos Initiative
+# Copyright 2017 The Mifos Initiative.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/service/src/main/resources/bootstrap.yml b/service/src/main/resources/bootstrap.yml
index b814525..6b9e3e8 100644
--- a/service/src/main/resources/bootstrap.yml
+++ b/service/src/main/resources/bootstrap.yml
@@ -1,5 +1,5 @@
#
-# Copyright 2017 The Mifos Initiative
+# Copyright 2017 The Mifos Initiative.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/service/src/main/resources/db/migrations/mariadb/V1__initial_setup.sql b/service/src/main/resources/db/migrations/mariadb/V1__initial_setup.sql
index 3719a09..fb1b54e 100644
--- a/service/src/main/resources/db/migrations/mariadb/V1__initial_setup.sql
+++ b/service/src/main/resources/db/migrations/mariadb/V1__initial_setup.sql
@@ -1,5 +1,5 @@
--
--- Copyright 2017 The Mifos Initiative
+-- Copyright 2017 The Mifos Initiative.
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.