Created constants in API for default tenant type setup.
Signed-off-by: Kai Zimmermann <kai.zimmermann@bosch-si.com>
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
/target/
|
||||
/bin/
|
||||
/.apt_generated/
|
||||
/.springBeans
|
||||
|
||||
@@ -23,19 +23,6 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class MgmtSoftwareModule extends MgmtNamedEntity {
|
||||
/**
|
||||
* API definition for Software module type#RUNTIME.
|
||||
*/
|
||||
public static final String SM_RUNTIME = "runtime";
|
||||
/**
|
||||
* API definition for for Software module type#OS.
|
||||
*/
|
||||
public static final String SM_OS = "os";
|
||||
/**
|
||||
* API definition for for Software module type#APPLICATION.
|
||||
*/
|
||||
public static final String SM_APPLICATION = "application";
|
||||
|
||||
@JsonProperty(value = "id", required = true)
|
||||
private Long moduleId;
|
||||
|
||||
|
||||
1
hawkbit-repository/.gitignore
vendored
Normal file
1
hawkbit-repository/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/.springBeans
|
||||
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
* Copyright (c) 2011-2016 Bosch Software Innovations GmbH, Germany. All rights reserved.
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||
|
||||
/**
|
||||
* Repository API constants.
|
||||
*
|
||||
*/
|
||||
public final class Constants {
|
||||
/**
|
||||
* Default {@link SoftwareModuleType} generated by repository for every new
|
||||
* account for Firmware/Operating System.
|
||||
*/
|
||||
public static final String SMT_DEFAULT_OS_KEY = "os";
|
||||
/**
|
||||
* Default {@link SoftwareModuleType} generated by repository for every new
|
||||
* account for applications.
|
||||
*/
|
||||
public static final String SMT_DEFAULT_APP_KEY = "application";
|
||||
|
||||
/**
|
||||
* {@link DistributionSetType#getKey()} of a {@link DistributionSetType}
|
||||
* generated by repository for every new account that includes
|
||||
* {@link #SMT_DEFAULT_OS_KEY} as mandatory module and optional
|
||||
* {@link #SMT_DEFAULT_APP_KEY}s.
|
||||
*/
|
||||
public static final String DST_DEFAULT_OS_WITH_APPS_KEY = "os_app";
|
||||
|
||||
/**
|
||||
* {@link DistributionSetType#getName()} of a {@link DistributionSetType}
|
||||
* generated by repository for every new account that includes
|
||||
* {@link #SMT_DEFAULT_OS_KEY} as mandatory module and optional
|
||||
* {@link #SMT_DEFAULT_APP_KEY}s.
|
||||
*/
|
||||
public static final String DST_DEFAULT_OS_WITH_APPS_NAME = "OS with app(s)";
|
||||
|
||||
/**
|
||||
* {@link DistributionSetType#getKey()} of a {@link DistributionSetType}
|
||||
* generated by repository for every new account that includes only
|
||||
* {@link #SMT_DEFAULT_OS_KEY} as mandatory module.
|
||||
*/
|
||||
public static final String DST_DEFAULT_OS_ONLY_KEY = "os";
|
||||
|
||||
/**
|
||||
* {@link DistributionSetType#getName()} of a {@link DistributionSetType}
|
||||
* generated by repository for every new account that includes only
|
||||
* {@link #SMT_DEFAULT_OS_KEY} as mandatory module.
|
||||
*/
|
||||
public static final String DST_DEFAULT_OS_ONLY_NAME = "OS only";
|
||||
|
||||
private Constants() {
|
||||
// Utility class.
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ import java.util.stream.Collectors;
|
||||
import javax.persistence.EntityManager;
|
||||
|
||||
import org.eclipse.hawkbit.cache.TenancyCacheManager;
|
||||
import org.eclipse.hawkbit.repository.Constants;
|
||||
import org.eclipse.hawkbit.repository.SystemManagement;
|
||||
import org.eclipse.hawkbit.repository.TenantStatsManagement;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||
@@ -283,16 +284,19 @@ public class JpaSystemManagement implements CurrentTenantCacheKeyGenerator, Syst
|
||||
}
|
||||
|
||||
private DistributionSetType createStandardSoftwareDataSetup() {
|
||||
final SoftwareModuleType app = softwareModuleTypeRepository
|
||||
.save(new JpaSoftwareModuleType("application", "Application", "Application Addons", Integer.MAX_VALUE));
|
||||
final SoftwareModuleType os = softwareModuleTypeRepository
|
||||
.save(new JpaSoftwareModuleType("os", "Firmware", "Core firmware or operationg system", 1));
|
||||
final SoftwareModuleType app = softwareModuleTypeRepository.save(new JpaSoftwareModuleType(
|
||||
Constants.SMT_DEFAULT_APP_KEY, "Application", "Application Addons", Integer.MAX_VALUE));
|
||||
final SoftwareModuleType os = softwareModuleTypeRepository.save(new JpaSoftwareModuleType(
|
||||
Constants.SMT_DEFAULT_OS_KEY, "Firmware", "Core firmware or operationg system", 1));
|
||||
|
||||
distributionSetTypeRepository.save((JpaDistributionSetType) new JpaDistributionSetType("os", "OS only",
|
||||
"Default type with Firmware/OS only.").addMandatoryModuleType(os));
|
||||
distributionSetTypeRepository
|
||||
.save((JpaDistributionSetType) new JpaDistributionSetType(Constants.DST_DEFAULT_OS_ONLY_KEY,
|
||||
Constants.DST_DEFAULT_OS_ONLY_NAME, "Default type with Firmware/OS only.")
|
||||
.addMandatoryModuleType(os));
|
||||
|
||||
return distributionSetTypeRepository.save((JpaDistributionSetType) new JpaDistributionSetType("os_app",
|
||||
"OS with app(s)", "Default type with Firmware/OS and optional app(s).").addMandatoryModuleType(os)
|
||||
.addOptionalModuleType(app));
|
||||
return distributionSetTypeRepository
|
||||
.save((JpaDistributionSetType) new JpaDistributionSetType(Constants.DST_DEFAULT_OS_WITH_APPS_KEY,
|
||||
Constants.DST_DEFAULT_OS_WITH_APPS_NAME, "Default type with Firmware/OS and optional app(s).")
|
||||
.addMandatoryModuleType(os).addOptionalModuleType(app));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import org.eclipse.hawkbit.repository.jpa.model.JpaSoftwareModule;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaSoftwareModuleMetadata;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata;
|
||||
import org.eclipse.hawkbit.repository.util.TestdataFactory;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.data.domain.Page;
|
||||
@@ -84,10 +85,10 @@ public class RSQLSoftwareModuleFieldTest extends AbstractJpaIntegrationTest {
|
||||
@Test
|
||||
@Description("Test filter software module by type")
|
||||
public void testFilterByType() {
|
||||
assertRSQLQuery(SoftwareModuleFields.TYPE.name() + "==application", 2);
|
||||
assertRSQLQuery(SoftwareModuleFields.TYPE.name() + "==" + TestdataFactory.SM_TYPE_APP, 2);
|
||||
assertRSQLQuery(SoftwareModuleFields.TYPE.name() + "==noExist*", 0);
|
||||
assertRSQLQuery(SoftwareModuleFields.TYPE.name() + "=in=(application)", 2);
|
||||
assertRSQLQuery(SoftwareModuleFields.TYPE.name() + "=out=(application)", 2);
|
||||
assertRSQLQuery(SoftwareModuleFields.TYPE.name() + "=in=(" + TestdataFactory.SM_TYPE_APP + ")", 2);
|
||||
assertRSQLQuery(SoftwareModuleFields.TYPE.name() + "=out=(" + TestdataFactory.SM_TYPE_APP + ")", 2);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user