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 bbb452993..69727bfbe 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 @@ -85,7 +85,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn .andExpect(jsonPath("$.content.[?(@.key==test123)]$..key", contains("test123"))) .andExpect(jsonPath("$.content.[?(@.key==test123)]$.._links.self.href", contains("http://localhost/rest/v1/distributionsettypes/" + testType.getId()))) - .andExpect(jsonPath("$.total", equalTo(4))); + .andExpect(jsonPath("$.total", equalTo(5))); } @Test @@ -116,14 +116,14 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn mvc.perform(get("/rest/v1/distributionsettypes").accept(MediaType.APPLICATION_JSON) .param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "KEY:ASC")).andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) - .andExpect(jsonPath("$.content.[3].id", equalTo(testType.getId().intValue()))) - .andExpect(jsonPath("$.content.[3].name", equalTo("TestName123"))) - .andExpect(jsonPath("$.content.[3].description", equalTo("Desc1234"))) - .andExpect(jsonPath("$.content.[3].createdBy", equalTo("uploadTester"))) - .andExpect(jsonPath("$.content.[3].createdAt", equalTo(testType.getCreatedAt()))) - .andExpect(jsonPath("$.content.[3].lastModifiedBy", equalTo("uploadTester"))) - .andExpect(jsonPath("$.content.[3].lastModifiedAt", equalTo(testType.getLastModifiedAt()))) - .andExpect(jsonPath("$.content.[3].key", equalTo("zzzzz"))) + .andExpect(jsonPath("$.content.[4].id", equalTo(testType.getId().intValue()))) + .andExpect(jsonPath("$.content.[4].name", equalTo("TestName123"))) + .andExpect(jsonPath("$.content.[4].description", equalTo("Desc1234"))) + .andExpect(jsonPath("$.content.[4].createdBy", equalTo("uploadTester"))) + .andExpect(jsonPath("$.content.[4].createdAt", equalTo(testType.getCreatedAt()))) + .andExpect(jsonPath("$.content.[4].lastModifiedBy", equalTo("uploadTester"))) + .andExpect(jsonPath("$.content.[4].lastModifiedAt", equalTo(testType.getLastModifiedAt()))) + .andExpect(jsonPath("$.content.[4].key", equalTo("zzzzz"))) .andExpect(jsonPath("$.total", equalTo(DEFAULT_DS_TYPES + 1))); } @@ -160,7 +160,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn JsonPath.compile("[2]_links.self.href").read(mvcResult.getResponse().getContentAsString()).toString()) .isEqualTo("http://localhost/rest/v1/distributionsettypes/" + created3.getId()); - assertThat(distributionSetTypeManagement.count()).isEqualTo(6); + assertThat(distributionSetTypeManagement.count()).isEqualTo(7); } @Step @@ -428,8 +428,8 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn @Description("Checks the correct behaviour of /rest/v1/distributionsettypes GET requests with paging.") public void getDistributionSetTypesWithoutAddtionalRequestParameters() throws Exception { - // 3 types overall (2 hawkbit tenant default, 1 test default - final int types = 3; + // 4 types overall (3 hawkbit tenant default, 1 test default + final int types = 4; mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING)).andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(types))) diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/Constants.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/Constants.java index 5dcb26638..2d3466c70 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/Constants.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/Constants.java @@ -70,6 +70,20 @@ public final class Constants { */ public static final String DST_DEFAULT_OS_ONLY_NAME = "OS only"; + /** + * {@link DistributionSetType#getKey()} of a {@link DistributionSetType} + * generated by repository for every new account that includes only + * {@link #SMT_DEFAULT_APP_KEY} as mandatory module. + */ + public static final String DST_DEFAULT_APP_ONLY_KEY = "app"; + + /** + * {@link DistributionSetType#getName()} of a {@link DistributionSetType} + * generated by repository for every new account that includes only + * {@link #SMT_DEFAULT_APP_KEY} as mandatory module. + */ + public static final String DST_DEFAULT_APP_ONLY_NAME = "App(s) only"; + private Constants() { // Utility class. } diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/RepositoryConstants.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/RepositoryConstants.java index 6a099cd48..e4d801b8e 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/RepositoryConstants.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/RepositoryConstants.java @@ -28,7 +28,7 @@ public final class RepositoryConstants { * Number of {@link DistributionSetType}s that are generated as part of * default tenant setup. */ - public static final int DEFAULT_DS_TYPES_IN_TENANT = 2; + public static final int DEFAULT_DS_TYPES_IN_TENANT = 3; /** * Maximum number of messages that can be retrieved by a controller for an diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaSystemManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaSystemManagement.java index 4c41ee2e4..c91d24421 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaSystemManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaSystemManagement.java @@ -302,6 +302,11 @@ public class JpaSystemManagement implements CurrentTenantCacheKeyGenerator, Syst org.eclipse.hawkbit.repository.Constants.DST_DEFAULT_OS_ONLY_NAME, "Default type with Firmware/OS only.").addMandatoryModuleType(os)); + distributionSetTypeRepository + .save(new JpaDistributionSetType(org.eclipse.hawkbit.repository.Constants.DST_DEFAULT_APP_ONLY_KEY, + org.eclipse.hawkbit.repository.Constants.DST_DEFAULT_APP_ONLY_NAME, + "Default type with app(s) only.").addMandatoryModuleType(app)); + return distributionSetTypeRepository .save(new JpaDistributionSetType(org.eclipse.hawkbit.repository.Constants.DST_DEFAULT_OS_WITH_APPS_KEY, org.eclipse.hawkbit.repository.Constants.DST_DEFAULT_OS_WITH_APPS_NAME, diff --git a/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/AbstractIntegrationTest.java b/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/AbstractIntegrationTest.java index 66b71d70e..c1c6e327d 100644 --- a/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/AbstractIntegrationTest.java +++ b/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/AbstractIntegrationTest.java @@ -114,7 +114,7 @@ public abstract class AbstractIntegrationTest { /** * Number of {@link DistributionSetType}s that exist in every test case. One * generated by using - * {@link TestdataFactory#findOrCreateDefaultTestDsType()} and two + * {@link TestdataFactory#findOrCreateDefaultTestDsType()} and three * {@link SystemManagement#getTenantMetadata()}; */ protected static final int DEFAULT_DS_TYPES = RepositoryConstants.DEFAULT_DS_TYPES_IN_TENANT + 1;