diff --git a/hawkbit-ddi-resource/pom.xml b/hawkbit-ddi-resource/pom.xml
index cafcfdf70..f73cb6c1e 100644
--- a/hawkbit-ddi-resource/pom.xml
+++ b/hawkbit-ddi-resource/pom.xml
@@ -28,7 +28,7 @@
org.eclipse.hawkbit
- hawkbit-rest-core
+ hawkbit-rest-core
${project.version}
@@ -40,6 +40,12 @@
+
+ org.eclipse.hawkbit
+ hawkbit-rest-core
+ ${project.version}
+ test
+
org.springframework.boot
spring-boot-starter
diff --git a/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiCancelActionTest.java b/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiCancelActionTest.java
index 27a7e7f1f..ddd826e8a 100644
--- a/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiCancelActionTest.java
+++ b/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiCancelActionTest.java
@@ -28,6 +28,8 @@ import org.eclipse.hawkbit.repository.model.Action;
import org.eclipse.hawkbit.repository.model.Action.Status;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.Target;
+import org.eclipse.hawkbit.rest.util.JsonBuilder;
+import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
import org.junit.Test;
import org.springframework.hateoas.MediaTypes;
import org.springframework.http.MediaType;
diff --git a/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiConfigDataTest.java b/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiConfigDataTest.java
index b757f1f1a..4a86cfe8c 100644
--- a/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiConfigDataTest.java
+++ b/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiConfigDataTest.java
@@ -23,6 +23,8 @@ import java.util.Map;
import org.eclipse.hawkbit.AbstractIntegrationTest;
import org.eclipse.hawkbit.repository.model.Target;
+import org.eclipse.hawkbit.rest.util.JsonBuilder;
+import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
import org.junit.Test;
import org.springframework.hateoas.MediaTypes;
import org.springframework.http.MediaType;
diff --git a/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiDeploymentBaseTest.java b/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiDeploymentBaseTest.java
index dd2f66a04..5c89291cc 100644
--- a/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiDeploymentBaseTest.java
+++ b/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiDeploymentBaseTest.java
@@ -35,6 +35,8 @@ import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.LocalArtifact;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
+import org.eclipse.hawkbit.rest.util.JsonBuilder;
+import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
import org.fest.assertions.core.Condition;
import org.junit.Test;
import org.springframework.data.domain.PageRequest;
diff --git a/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiRootControllerTest.java b/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiRootControllerTest.java
index f291393b9..407ff63d0 100644
--- a/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiRootControllerTest.java
+++ b/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiRootControllerTest.java
@@ -32,6 +32,8 @@ import org.eclipse.hawkbit.repository.model.Action;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
+import org.eclipse.hawkbit.rest.util.JsonBuilder;
+import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationKey;
import org.eclipse.hawkbit.util.IpUtil;
import org.junit.Test;
diff --git a/hawkbit-mgmt-resource/pom.xml b/hawkbit-mgmt-resource/pom.xml
index 311cbae76..cc95f8026 100644
--- a/hawkbit-mgmt-resource/pom.xml
+++ b/hawkbit-mgmt-resource/pom.xml
@@ -31,6 +31,12 @@
+
+ org.eclipse.hawkbit
+ hawkbit-rest-core
+ ${project.version}
+ test
+
org.springframework.boot
spring-boot-starter
diff --git a/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/JsonBuilder.java b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/JsonBuilder.java
deleted file mode 100644
index 5a9f2785a..000000000
--- a/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/JsonBuilder.java
+++ /dev/null
@@ -1,466 +0,0 @@
-/**
- * Copyright (c) 2015 Bosch Software Innovations GmbH and others.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- */
-package org.eclipse.hawkbit.mgmt.rest.resource;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-
-import org.apache.commons.lang3.RandomStringUtils;
-import org.eclipse.hawkbit.repository.model.DistributionSet;
-import org.eclipse.hawkbit.repository.model.DistributionSetType;
-import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupConditions;
-import org.eclipse.hawkbit.repository.model.SoftwareModule;
-import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
-import org.eclipse.hawkbit.repository.model.Target;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
-/**
- * Builder class for building certain json strings.
- *
- *
- *
- */
-public abstract class JsonBuilder {
-
- public static String softwareModules(final List modules) throws JSONException {
- final StringBuilder builder = new StringBuilder();
-
- builder.append("[");
- int i = 0;
- for (final SoftwareModule module : modules) {
- try {
- builder.append(new JSONObject().put("name", module.getName())
- .put("description", module.getDescription()).put("type", module.getType().getKey())
- .put("id", Long.MAX_VALUE).put("vendor", module.getVendor())
- .put("version", module.getVersion()).put("createdAt", "0").put("updatedAt", "0")
- .put("createdBy", "fghdfkjghdfkjh").put("updatedBy", "fghdfkjghdfkjh").toString());
- } catch (final Exception e) {
- e.printStackTrace();
- }
-
- if (++i < modules.size()) {
- builder.append(",");
- }
- }
-
- builder.append("]");
-
- return builder.toString();
-
- }
-
- public static String softwareModulesCreatableFieldsOnly(final List modules) throws JSONException {
- final StringBuilder builder = new StringBuilder();
-
- builder.append("[");
- int i = 0;
- for (final SoftwareModule module : modules) {
- try {
- builder.append(new JSONObject().put("name", module.getName())
- .put("description", module.getDescription()).put("type", module.getType().getKey())
- .put("vendor", module.getVendor()).put("version", module.getVersion()).toString());
- } catch (final Exception e) {
- e.printStackTrace();
- }
-
- if (++i < modules.size()) {
- builder.append(",");
- }
- }
-
- builder.append("]");
-
- return builder.toString();
-
- }
-
- public static String softwareModuleUpdatableFieldsOnly(final SoftwareModule module) throws JSONException {
- final StringBuilder builder = new StringBuilder();
-
- builder.append(new JSONObject().put("description", module.getDescription()).put("vendor", module.getVendor())
- .toString());
-
- return builder.toString();
-
- }
-
- public static String softwareModuleTypes(final List types) throws JSONException {
- final StringBuilder builder = new StringBuilder();
-
- builder.append("[");
- int i = 0;
- for (final SoftwareModuleType module : types) {
- try {
- builder.append(new JSONObject().put("name", module.getName())
- .put("description", module.getDescription()).put("id", Long.MAX_VALUE)
- .put("key", module.getKey()).put("maxAssignments", module.getMaxAssignments())
- .put("createdAt", "0").put("updatedAt", "0").put("createdBy", "fghdfkjghdfkjh")
- .put("updatedBy", "fghdfkjghdfkjh").toString());
- } catch (final Exception e) {
- e.printStackTrace();
- }
-
- if (++i < types.size()) {
- builder.append(",");
- }
- }
-
- builder.append("]");
-
- return builder.toString();
-
- }
-
- public static String softwareModuleTypesCreatableFieldsOnly(final List types)
- throws JSONException {
- final StringBuilder builder = new StringBuilder();
-
- builder.append("[");
- int i = 0;
- for (final SoftwareModuleType module : types) {
- try {
- builder.append(new JSONObject().put("name", module.getName())
- .put("description", module.getDescription()).put("key", module.getKey())
- .put("maxAssignments", module.getMaxAssignments()).toString());
- } catch (final Exception e) {
- e.printStackTrace();
- }
-
- if (++i < types.size()) {
- builder.append(",");
- }
- }
-
- builder.append("]");
-
- return builder.toString();
-
- }
-
- /**
- * builds a json string for the feedback for the execution "proceeding".
- *
- * @param id
- * of the Action feedback refers to
- * @return the built string
- * @throws JSONException
- */
- public static String deploymentActionInProgressFeedback(final String id) throws JSONException {
- return deploymentActionFeedback(id, "proceeding");
- }
-
- /**
- * builds a certain json string for a action feedback.
- *
- * @param id
- * of the action the feedback refers to
- * @param execution
- * see ExecutionStatus
- * @return the build json string
- * @throws JSONException
- */
- public static String deploymentActionFeedback(final String id, final String execution) throws JSONException {
- return deploymentActionFeedback(id, execution, "none", RandomStringUtils.randomAscii(1000));
-
- }
-
- public static String deploymentActionFeedback(final String id, final String execution, final String message)
- throws JSONException {
- return deploymentActionFeedback(id, execution, "none", message);
-
- }
-
- public static String deploymentActionFeedback(final String id, final String execution, final String finished,
- final String message) throws JSONException {
- final List messages = new ArrayList();
- messages.add(message);
-
- return new JSONObject()
- .put("id", id)
- .put("time", "20140511T121314")
- .put("status",
- new JSONObject()
- .put("execution", execution)
- .put("result",
- new JSONObject().put("finished", finished).put("progress",
- new JSONObject().put("cnt", 2).put("of", 5))).put("details", messages))
- .toString();
-
- }
-
- /**
- * @param types
- * @return
- */
- public static String distributionSetTypes(final List types) {
- final StringBuilder builder = new StringBuilder();
-
- builder.append("[");
- int i = 0;
- for (final DistributionSetType module : types) {
-
- try {
-
- final JSONArray osmTypes = new JSONArray();
- module.getOptionalModuleTypes().forEach(smt -> osmTypes.put(new JSONObject().put("id", smt.getId())));
-
- final JSONArray msmTypes = new JSONArray();
- module.getMandatoryModuleTypes().forEach(smt -> msmTypes.put(new JSONObject().put("id", smt.getId())));
-
- builder.append(new JSONObject().put("name", module.getName())
- .put("description", module.getDescription()).put("id", Long.MAX_VALUE)
- .put("key", module.getKey()).put("createdAt", "0").put("updatedAt", "0")
- .put("createdBy", "fghdfkjghdfkjh").put("optionalmodules", osmTypes)
- .put("mandatorymodules", msmTypes).put("updatedBy", "fghdfkjghdfkjh").toString());
- } catch (final Exception e) {
- e.printStackTrace();
- }
-
- if (++i < types.size()) {
- builder.append(",");
- }
- }
-
- builder.append("]");
-
- return builder.toString();
- }
-
- public static String distributionSetTypesCreateValidFieldsOnly(final List types) {
- final StringBuilder builder = new StringBuilder();
-
- builder.append("[");
- int i = 0;
- for (final DistributionSetType module : types) {
-
- try {
-
- final JSONArray osmTypes = new JSONArray();
- module.getOptionalModuleTypes().forEach(smt -> osmTypes.put(new JSONObject().put("id", smt.getId())));
-
- final JSONArray msmTypes = new JSONArray();
- module.getMandatoryModuleTypes().forEach(smt -> msmTypes.put(new JSONObject().put("id", smt.getId())));
-
- builder.append(new JSONObject().put("name", module.getName())
- .put("description", module.getDescription()).put("key", module.getKey())
- .put("optionalmodules", osmTypes).put("mandatorymodules", msmTypes).toString());
- } catch (final Exception e) {
- e.printStackTrace();
- }
-
- if (++i < types.size()) {
- builder.append(",");
- }
- }
-
- builder.append("]");
-
- return builder.toString();
- }
-
- public static String distributionSets(final List sets) throws JSONException {
- final StringBuilder builder = new StringBuilder();
-
- builder.append("[");
- int i = 0;
- for (final DistributionSet set : sets) {
- try {
- builder.append(distributionSet(set));
- } catch (final Exception e) {
- e.printStackTrace();
- }
-
- if (++i < sets.size()) {
- builder.append(",");
- }
- }
-
- builder.append("]");
-
- return builder.toString();
-
- }
-
- public static String distributionSetsCreateValidFieldsOnly(final List sets) throws JSONException {
- final StringBuilder builder = new StringBuilder();
-
- builder.append("[");
- int i = 0;
- for (final DistributionSet set : sets) {
- try {
- builder.append(distributionSetCreateValidFieldsOnly(set));
- } catch (final Exception e) {
- e.printStackTrace();
- }
-
- if (++i < sets.size()) {
- builder.append(",");
- }
- }
-
- builder.append("]");
-
- return builder.toString();
-
- }
-
- public static String distributionSetCreateValidFieldsOnly(final DistributionSet set) throws JSONException {
-
- final List modules = set.getModules().stream().map(module -> {
- try {
- return new JSONObject().put("id", module.getId());
- } catch (final Exception e) {
- e.printStackTrace();
- }
-
- return null;
- }).collect(Collectors.toList());
-
- return new JSONObject().put("name", set.getName()).put("description", set.getDescription())
- .put("type", set.getType() == null ? null : set.getType().getKey()).put("version", set.getVersion())
- .put("requiredMigrationStep", set.isRequiredMigrationStep()).put("modules", modules).toString();
-
- }
-
- public static String distributionSetUpdateValidFieldsOnly(final DistributionSet set) throws JSONException {
-
- final List modules = set.getModules().stream().map(module -> {
- try {
- return new JSONObject().put("id", module.getId());
- } catch (final Exception e) {
- e.printStackTrace();
- }
-
- return null;
- }).collect(Collectors.toList());
-
- return new JSONObject().put("name", set.getName()).put("description", set.getDescription())
- .put("version", set.getVersion()).toString();
-
- }
-
- public static String distributionSet(final DistributionSet set) throws JSONException {
-
- final List modules = set.getModules().stream().map(module -> {
- try {
- return new JSONObject().put("id", module.getId());
- } catch (final Exception e) {
- e.printStackTrace();
- }
-
- return null;
- }).collect(Collectors.toList());
-
- return new JSONObject().put("name", set.getName()).put("description", set.getDescription())
- .put("type", set.getType() == null ? null : set.getType().getKey()).put("id", Long.MAX_VALUE)
- .put("version", set.getVersion()).put("createdAt", "0").put("updatedAt", "0")
- .put("createdBy", "fghdfkjghdfkjh").put("updatedBy", "fghdfkjghdfkjh")
- .put("requiredMigrationStep", set.isRequiredMigrationStep()).put("modules", modules).toString();
-
- }
-
- /**
- * @param targets
- * @return
- */
- public static String targets(final List targets) {
- final StringBuilder builder = new StringBuilder();
-
- builder.append("[");
- int i = 0;
- for (final Target target : targets) {
- try {
- builder.append(new JSONObject().put("controllerId", target.getControllerId())
- .put("description", target.getDescription()).put("name", target.getName())
- .put("createdAt", "0").put("updatedAt", "0").put("createdBy", "fghdfkjghdfkjh")
- .put("updatedBy", "fghdfkjghdfkjh").toString());
- } catch (final Exception e) {
- e.printStackTrace();
- }
-
- if (++i < targets.size()) {
- builder.append(",");
- }
- }
-
- builder.append("]");
-
- return builder.toString();
- }
-
- public static String rollout(final String name, final String description, final int groupSize,
- final long distributionSetId, final String targetFilterQuery, final RolloutGroupConditions conditions) {
- final JSONObject json = new JSONObject();
- json.put("name", name);
- json.put("description", description);
- json.put("amountGroups", groupSize);
- json.put("distributionSetId", distributionSetId);
- json.put("targetFilterQuery", targetFilterQuery);
-
- if (conditions != null) {
- final JSONObject successCondition = new JSONObject();
- json.put("successCondition", successCondition);
- successCondition.put("condition", conditions.getSuccessCondition().toString());
- successCondition.put("expression", conditions.getSuccessConditionExp().toString());
-
- final JSONObject successAction = new JSONObject();
- json.put("successAction", successAction);
- successAction.put("action", conditions.getSuccessAction().toString());
- successAction.put("expression", conditions.getSuccessActionExp().toString());
-
- final JSONObject errorCondition = new JSONObject();
- json.put("errorCondition", errorCondition);
- errorCondition.put("condition", conditions.getErrorCondition().toString());
- errorCondition.put("expression", conditions.getErrorConditionExp().toString());
-
- final JSONObject errorAction = new JSONObject();
- json.put("errorAction", errorAction);
- errorAction.put("action", conditions.getErrorAction().toString());
- errorAction.put("expression", conditions.getErrorActionExp().toString());
- }
-
- return json.toString();
- }
-
- public static String cancelActionFeedback(final String id, final String execution) throws JSONException {
- return cancelActionFeedback(id, execution, RandomStringUtils.randomAscii(1000));
-
- }
-
- public static String cancelActionFeedback(final String id, final String execution, final String message)
- throws JSONException {
- final List messages = new ArrayList();
- messages.add(message);
- return new JSONObject()
- .put("id", id)
- .put("time", "20140511T121314")
- .put("status",
- new JSONObject().put("execution", execution)
- .put("result", new JSONObject().put("finished", "success")).put("details", messages))
- .toString();
-
- }
-
- public static String configData(final String id, final Map attributes, final String execution)
- throws JSONException {
- return new JSONObject()
- .put("id", id)
- .put("time", "20140511T121314")
- .put("status",
- new JSONObject().put("execution", execution)
- .put("result", new JSONObject().put("finished", "success"))
- .put("details", new ArrayList())).put("data", attributes).toString();
-
- }
-
-}
diff --git a/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetResourceTest.java b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetResourceTest.java
index b7839f7f6..61a84fdd8 100644
--- a/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetResourceTest.java
+++ b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetResourceTest.java
@@ -44,6 +44,8 @@ import org.eclipse.hawkbit.repository.model.DistributionSetMetadata;
import org.eclipse.hawkbit.repository.model.DsMetadataCompositeKey;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.Target;
+import org.eclipse.hawkbit.rest.util.JsonBuilder;
+import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
diff --git a/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeResourceTest.java b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeResourceTest.java
index b2f309995..8bc8c6ca9 100644
--- a/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeResourceTest.java
+++ b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeResourceTest.java
@@ -30,6 +30,8 @@ import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
+import org.eclipse.hawkbit.rest.util.JsonBuilder;
+import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
import org.json.JSONException;
import org.json.JSONObject;
import org.junit.Test;
diff --git a/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDownloadResourceTest.java b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDownloadResourceTest.java
index 2311b098c..1122f3ed4 100644
--- a/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDownloadResourceTest.java
+++ b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDownloadResourceTest.java
@@ -20,6 +20,7 @@ import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.eclipse.hawkbit.repository.model.Artifact;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
+import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
diff --git a/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutResourceTest.java b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutResourceTest.java
index f33ceb942..35ab7a786 100644
--- a/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutResourceTest.java
+++ b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutResourceTest.java
@@ -25,7 +25,6 @@ import org.eclipse.hawkbit.AbstractIntegrationTest;
import org.eclipse.hawkbit.TestDataUtil;
import org.eclipse.hawkbit.WithUser;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
-import org.eclipse.hawkbit.mgmt.rest.resource.MgmtRolloutResource;
import org.eclipse.hawkbit.repository.RolloutGroupManagement;
import org.eclipse.hawkbit.repository.RolloutManagement;
import org.eclipse.hawkbit.repository.model.DistributionSet;
@@ -35,6 +34,9 @@ import org.eclipse.hawkbit.repository.model.RolloutGroup;
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupConditionBuilder;
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupSuccessCondition;
import org.eclipse.hawkbit.repository.model.Target;
+import org.eclipse.hawkbit.rest.util.JsonBuilder;
+import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
+import org.eclipse.hawkbit.rest.util.SuccessCondition;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Description;
diff --git a/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleResourceTest.java b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleResourceTest.java
index f6a945a29..dbce7d90e 100644
--- a/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleResourceTest.java
+++ b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleResourceTest.java
@@ -47,6 +47,8 @@ import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata;
import org.eclipse.hawkbit.repository.model.SwMetadataCompositeKey;
import org.eclipse.hawkbit.rest.json.model.ExceptionInfo;
+import org.eclipse.hawkbit.rest.util.JsonBuilder;
+import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
diff --git a/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeResourceTest.java b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeResourceTest.java
index d8d113fbc..aa2cd68e2 100644
--- a/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeResourceTest.java
+++ b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeResourceTest.java
@@ -28,6 +28,8 @@ import org.eclipse.hawkbit.WithUser;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
+import org.eclipse.hawkbit.rest.util.JsonBuilder;
+import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
import org.json.JSONException;
import org.json.JSONObject;
import org.junit.Test;
diff --git a/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetResourceTest.java b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetResourceTest.java
index 6954aee31..fff9d8d2e 100644
--- a/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetResourceTest.java
+++ b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetResourceTest.java
@@ -48,6 +48,8 @@ import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetInfo;
import org.eclipse.hawkbit.rest.exception.MessageNotReadableException;
import org.eclipse.hawkbit.rest.json.model.ExceptionInfo;
+import org.eclipse.hawkbit.rest.util.JsonBuilder;
+import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
import org.eclipse.hawkbit.util.IpUtil;
import org.json.JSONException;
import org.json.JSONObject;
diff --git a/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MockMvcResultPrinter.java b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MockMvcResultPrinter.java
deleted file mode 100644
index 7d07b3bd3..000000000
--- a/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MockMvcResultPrinter.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * Copyright (c) 2015 Bosch Software Innovations GmbH and others.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- */
-package org.eclipse.hawkbit.mgmt.rest.resource;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.test.web.servlet.MvcResult;
-import org.springframework.test.web.servlet.ResultHandler;
-import org.springframework.test.web.servlet.result.PrintingResultHandler;
-import org.springframework.util.CollectionUtils;
-
-public abstract class MockMvcResultPrinter {
- private static final Logger LOG = LoggerFactory.getLogger(MockMvcResultPrinter.class);
-
- private MockMvcResultPrinter() {
- }
-
- /**
- * Print {@link MvcResult} details to the "standard" output stream.
- */
- public static ResultHandler print() {
- return new ConsolePrintingResultHandler();
- }
-
- /**
- * An {@link PrintingResultHandler} that writes to the "standard" output
- * stream
- */
- private static class ConsolePrintingResultHandler extends PrintingResultHandler {
-
- public ConsolePrintingResultHandler() {
- super(new ResultValuePrinter() {
-
- @Override
- public void printHeading(final String heading) {
- LOG.debug(String.format("%20s:", heading));
- }
-
- @Override
- public void printValue(final String label, Object value) {
- if (value != null && value.getClass().isArray()) {
- value = CollectionUtils.arrayToList(value);
- }
- LOG.debug(String.format("%20s = %s", label, value));
- }
- });
- }
- }
-}
diff --git a/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/SMRessourceMisingMongoDbConnectionTest.java b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/SMRessourceMisingMongoDbConnectionTest.java
index 4f80728f1..15d22c703 100644
--- a/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/SMRessourceMisingMongoDbConnectionTest.java
+++ b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/SMRessourceMisingMongoDbConnectionTest.java
@@ -17,6 +17,7 @@ import org.eclipse.hawkbit.AbstractIntegrationTest;
import org.eclipse.hawkbit.exception.SpServerError;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.rest.json.model.ExceptionInfo;
+import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.mock.web.MockMultipartFile;
diff --git a/hawkbit-rest-core/pom.xml b/hawkbit-rest-core/pom.xml
index 9048cf677..f731a35a3 100644
--- a/hawkbit-rest-core/pom.xml
+++ b/hawkbit-rest-core/pom.xml
@@ -55,5 +55,31 @@
allure-junit-adaptor
test
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ org.json
+ json
+ test
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+
+
+
+ test-jar
+
+
+
+
+
+
\ No newline at end of file
diff --git a/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/JsonBuilder.java b/hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/util/JsonBuilder.java
similarity index 99%
rename from hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/JsonBuilder.java
rename to hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/util/JsonBuilder.java
index cf791bcf8..b73320f0e 100644
--- a/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/JsonBuilder.java
+++ b/hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/util/JsonBuilder.java
@@ -6,7 +6,7 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
-package org.eclipse.hawkbit.ddi.rest.resource;
+package org.eclipse.hawkbit.rest.util;
import java.util.ArrayList;
import java.util.List;
diff --git a/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/MockMvcResultPrinter.java b/hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/util/MockMvcResultPrinter.java
similarity index 97%
rename from hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/MockMvcResultPrinter.java
rename to hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/util/MockMvcResultPrinter.java
index ba5020c58..b1de56f61 100644
--- a/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/MockMvcResultPrinter.java
+++ b/hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/util/MockMvcResultPrinter.java
@@ -6,7 +6,7 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
-package org.eclipse.hawkbit.ddi.rest.resource;
+package org.eclipse.hawkbit.rest.util;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/SuccessCondition.java b/hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/util/SuccessCondition.java
similarity index 91%
rename from hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/SuccessCondition.java
rename to hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/util/SuccessCondition.java
index cafc36b0b..f3424b0c0 100644
--- a/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/SuccessCondition.java
+++ b/hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/util/SuccessCondition.java
@@ -6,7 +6,7 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
-package org.eclipse.hawkbit.mgmt.rest.resource;
+package org.eclipse.hawkbit.rest.util;
/**
*
diff --git a/hawkbit-rest-core/src/test/resources/log4j2.xml b/hawkbit-rest-core/src/test/resources/log4j2.xml
deleted file mode 100644
index 98ea99ac9..000000000
--- a/hawkbit-rest-core/src/test/resources/log4j2.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/hawkbit-system-resource/pom.xml b/hawkbit-system-resource/pom.xml
index fed198db3..6b02cf70c 100644
--- a/hawkbit-system-resource/pom.xml
+++ b/hawkbit-system-resource/pom.xml
@@ -31,6 +31,12 @@
+
+ org.eclipse.hawkbit
+ hawkbit-rest-core
+ ${project.version}
+ test
+
org.springframework.boot
spring-boot-starter-test
diff --git a/hawkbit-system-resource/src/test/java/org/eclipse/hawkbit/system/rest/resource/MockMvcResultPrinter.java b/hawkbit-system-resource/src/test/java/org/eclipse/hawkbit/system/rest/resource/MockMvcResultPrinter.java
deleted file mode 100644
index de82640dc..000000000
--- a/hawkbit-system-resource/src/test/java/org/eclipse/hawkbit/system/rest/resource/MockMvcResultPrinter.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * Copyright (c) 2015 Bosch Software Innovations GmbH and others.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- */
-package org.eclipse.hawkbit.system.rest.resource;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.test.web.servlet.MvcResult;
-import org.springframework.test.web.servlet.ResultHandler;
-import org.springframework.test.web.servlet.result.PrintingResultHandler;
-import org.springframework.util.CollectionUtils;
-
-public abstract class MockMvcResultPrinter {
- private static final Logger LOG = LoggerFactory.getLogger(MockMvcResultPrinter.class);
-
- private MockMvcResultPrinter() {
- }
-
- /**
- * Print {@link MvcResult} details to the "standard" output stream.
- */
- public static ResultHandler print() {
- return new ConsolePrintingResultHandler();
- }
-
- /**
- * An {@link PrintingResultHandler} that writes to the "standard" output
- * stream
- */
- private static class ConsolePrintingResultHandler extends PrintingResultHandler {
-
- public ConsolePrintingResultHandler() {
- super(new ResultValuePrinter() {
-
- @Override
- public void printHeading(final String heading) {
- LOG.debug(String.format("%20s:", heading));
- }
-
- @Override
- public void printValue(final String label, Object value) {
- if (value != null && value.getClass().isArray()) {
- value = CollectionUtils.arrayToList(value);
- }
- LOG.debug(String.format("%20s = %s", label, value));
- }
- });
- }
- }
-}
diff --git a/hawkbit-system-resource/src/test/java/org/eclipse/hawkbit/system/rest/resource/SystemManagementResourceTest.java b/hawkbit-system-resource/src/test/java/org/eclipse/hawkbit/system/rest/resource/SystemManagementResourceTest.java
index 38a8f1b11..fb98a8470 100644
--- a/hawkbit-system-resource/src/test/java/org/eclipse/hawkbit/system/rest/resource/SystemManagementResourceTest.java
+++ b/hawkbit-system-resource/src/test/java/org/eclipse/hawkbit/system/rest/resource/SystemManagementResourceTest.java
@@ -28,6 +28,7 @@ import org.eclipse.hawkbit.im.authentication.SpPermission;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.Target;
+import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
import org.junit.Test;
import org.springframework.http.MediaType;
diff --git a/hawkbit-system-resource/src/test/java/org/eclipse/hawkbit/system/rest/resource/SystemResourceTest.java b/hawkbit-system-resource/src/test/java/org/eclipse/hawkbit/system/rest/resource/SystemResourceTest.java
index 13ccf0999..abb61ef67 100644
--- a/hawkbit-system-resource/src/test/java/org/eclipse/hawkbit/system/rest/resource/SystemResourceTest.java
+++ b/hawkbit-system-resource/src/test/java/org/eclipse/hawkbit/system/rest/resource/SystemResourceTest.java
@@ -22,6 +22,7 @@ import org.eclipse.hawkbit.AbstractIntegrationTest;
import org.eclipse.hawkbit.exception.SpServerError;
import org.eclipse.hawkbit.repository.model.TenantConfigurationValue;
import org.eclipse.hawkbit.rest.json.model.ExceptionInfo;
+import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
import org.eclipse.hawkbit.system.rest.api.SystemRestConstant;
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationKey;
import org.junit.Test;
diff --git a/hawkbit-system-resource/src/test/resources/application-test.properties b/hawkbit-system-resource/src/test/resources/application-test.properties
deleted file mode 100644
index 92506caa4..000000000
--- a/hawkbit-system-resource/src/test/resources/application-test.properties
+++ /dev/null
@@ -1,63 +0,0 @@
-#
-# Copyright (c) 2015 Bosch Software Innovations GmbH and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-
-# used if IM profile is disabled
-security.ignored=true
-
-# IM required for integration tests
-spring.profiles.active=im,suiteembedded,artifactrepository,redis
-
-server.port=12222
-
-spring.data.mongodb.uri=mongodb://localhost/spArtifactRepository${random.value}
-spring.data.mongodb.port=28017
-
-
-# supported: H2, MYSQL
-hawkbit.server.database=H2
-hawkbit.server.database.env=TEST
-spring.main.show_banner=false
-
-hawkbit.server.ddi.security.authentication.header=true
-
-hawkbit.server.artifact.repo.upload.maxFileSize=5MB
-
-hawkbit.server.security.dos.maxStatusEntriesPerAction=100
-
-hawkbit.server.security.dos.maxAttributeEntriesPerTarget=10
-
-spring.jpa.database=${hawkbit.server.database}
-#spring.jpa.show-sql=true
-
-
-flyway.sqlMigrationSuffix=${spring.jpa.database}.sql
-
-# effective DB setting
-spring.datasource.url=${${hawkbit.server.database}.spring.datasource.url}
-spring.datasource.driverClassName=${${hawkbit.server.database}.spring.datasource.driverClassName}
-spring.datasource.username=${${hawkbit.server.database}.spring.datasource.username}
-spring.datasource.password=${${hawkbit.server.database}.spring.datasource.password}
-
-# H2
-##;AUTOCOMMIT=ON
-H2.spring.datasource.url=jdbc:h2:mem:sp-db;DB_CLOSE_ON_EXIT=FALSE
-#H2.spring.datasource.url=jdbc:h2:./db/sp-db;AUTO_SERVER=TRUE;DB_CLOSE_ON_EXIT=FALSE;MVCC=TRUE
-H2.spring.datasource.driverClassName=org.h2.Driver
-H2.spring.datasource.username=sa
-H2.spring.datasource.password=sa
-
-# MYSQL
-MYSQL.spring.datasource.url=jdbc:mysql://localhost:3306/sp_test
-MYSQL.spring.datasource.driverClassName=org.mariadb.jdbc.Driver
-MYSQL.spring.datasource.username=root
-MYSQL.spring.datasource.password=
-
-# SP Controller configuration
-hawkbit.controller.pollingTime=00:01:00
-hawkbit.controller.pollingOverdueTime=00:01:00