Add an "App(s) only" distribution set (#614)

Signed-off-by: Cedric Hombourger <Cedric_Hombourger@mentor.com>
This commit is contained in:
Cedric Hombourger
2017-12-16 11:31:46 +01:00
committed by Kai Zimmermann
parent 5175fc9521
commit c3035231e2
5 changed files with 33 additions and 14 deletions

View File

@@ -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)))

View File

@@ -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.
}

View File

@@ -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

View File

@@ -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,

View File

@@ -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;