From 3ac8dc93a3e96ae3fc13243960bf33f23d85eb49 Mon Sep 17 00:00:00 2001 From: Melanie Retter Date: Wed, 24 Aug 2016 09:49:05 +0200 Subject: [PATCH] Add Test for SoftwareManagement#createSoftwareModuleType Signed-off-by: Melanie Retter --- ...__software_module_type_constraint__H2.sql} | 0 ...oftware_module_type_constraint__MYSQL.sql} | 0 .../jpa/SoftwareManagementTest.java | 19 +++++++++++++++---- 3 files changed, 15 insertions(+), 4 deletions(-) rename hawkbit-repository/hawkbit-repository-jpa/src/main/resources/db/migration/H2/{V1_9_0__software_module_type_constraint__H2.sql => V1_7_0__software_module_type_constraint__H2.sql} (100%) rename hawkbit-repository/hawkbit-repository-jpa/src/main/resources/db/migration/MYSQL/{V1_9_0__software_module_type_constraint__MYSQL.sql => V1_7_0__software_module_type_constraint__MYSQL.sql} (100%) diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/resources/db/migration/H2/V1_9_0__software_module_type_constraint__H2.sql b/hawkbit-repository/hawkbit-repository-jpa/src/main/resources/db/migration/H2/V1_7_0__software_module_type_constraint__H2.sql similarity index 100% rename from hawkbit-repository/hawkbit-repository-jpa/src/main/resources/db/migration/H2/V1_9_0__software_module_type_constraint__H2.sql rename to hawkbit-repository/hawkbit-repository-jpa/src/main/resources/db/migration/H2/V1_7_0__software_module_type_constraint__H2.sql diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/resources/db/migration/MYSQL/V1_9_0__software_module_type_constraint__MYSQL.sql b/hawkbit-repository/hawkbit-repository-jpa/src/main/resources/db/migration/MYSQL/V1_7_0__software_module_type_constraint__MYSQL.sql similarity index 100% rename from hawkbit-repository/hawkbit-repository-jpa/src/main/resources/db/migration/MYSQL/V1_9_0__software_module_type_constraint__MYSQL.sql rename to hawkbit-repository/hawkbit-repository-jpa/src/main/resources/db/migration/MYSQL/V1_7_0__software_module_type_constraint__MYSQL.sql diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/SoftwareManagementTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/SoftwareManagementTest.java index 75633a85a..739cf7f64 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/SoftwareManagementTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/SoftwareManagementTest.java @@ -19,6 +19,8 @@ import java.util.Collections; import java.util.Iterator; import java.util.List; +import javax.validation.ConstraintViolationException; + import org.apache.commons.lang3.RandomUtils; import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; @@ -785,9 +787,20 @@ public class SoftwareManagementTest extends AbstractJpaIntegrationTestWithMongoD } } + @Test + @Description("Verifies that the creation of a softwareModuleType is failing because of invalid max assignment") + public void createSoftwareModuleTypesFailsWithInvalidMaxAssignment() { + try { + softwareManagement.createSoftwareModuleType(new JpaSoftwareModuleType("type", "name", "desc", 0)); + fail("should not have worked as max assignment is invalid. Should be greater than 0."); + } catch (final ConstraintViolationException e) { + + } + } + @Test @Description("Verfies that multiple types are created as requested.") - public void createMultipleoftwareModuleTypes() { + public void createMultipleSoftwareModuleTypes() { final List created = softwareManagement.createSoftwareModuleType( Lists.newArrayList(new JpaSoftwareModuleType("thetype", "thename", "desc", 100), new JpaSoftwareModuleType("thetype2", "thename2", "desc2", 100))); @@ -797,7 +810,7 @@ public class SoftwareManagementTest extends AbstractJpaIntegrationTestWithMongoD } @Test - @Description("Verfies that sofwtare modules are resturned that are assigned to given DS.") + @Description("Verfies that software modules are resturned that are assigned to given DS.") public void findSoftwareModuleByAssignedTo() { // test meta data final SoftwareModuleType testType = softwareManagement @@ -810,8 +823,6 @@ public class SoftwareManagementTest extends AbstractJpaIntegrationTestWithMongoD softwareManagement.createSoftwareModule(new JpaSoftwareModule(testType, "asis", "found", null, "")); final SoftwareModule one = softwareManagement .createSoftwareModule(new JpaSoftwareModule(testType, "found", "b", null, "")); - final SoftwareModule two = softwareManagement - .createSoftwareModule(new JpaSoftwareModule(testType, "found", "c", null, "")); // one soft deleted final SoftwareModule deleted = softwareManagement