Feature target type entity (#1162)
* Added Target Type model Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added Target Type JPA model Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added Target Type repository model classes Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Removed the name entity from Target Type Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Refactored the Target Type models Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added the DB migration script and updated the Target Type models Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added target type in target Mapper Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Changed the target type ID to Long Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added MYSQL DB migration script and removed the deleted column for target type Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Updated the DB migration script for target table Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added manyToMany reltation between target type and Ds type Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added POSTGRESQL DB migration script Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added MSSQL SERVER DB migration script Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added DB2 DB migration script Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added missing license header and java docs Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added on delete cascade in DB migration script Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added Target Type specification Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Removed the delete cascade and Added type API Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * fixed API doc build Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added target type management test Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added target type events test Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added target type update and unassign to target Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added API tests for assigning target type to target Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added missing license header Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added missing docs Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Fixed sonar issues Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Fixed license header build issue Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Updated the attribute name to target type Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Fixed the review comments Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Removed unused error status variable Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added target API to assign target type Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Added the tests for assigning target type to target Signed-off-by: Anand kumar <anand.kumar@bosch-si.com> * Fixed the review comments for null check Signed-off-by: Anand kumar <anand.kumar@bosch-si.com>
This commit is contained in:
@@ -44,6 +44,7 @@ import org.eclipse.hawkbit.repository.SystemManagement;
|
||||
import org.eclipse.hawkbit.repository.TargetFilterQueryManagement;
|
||||
import org.eclipse.hawkbit.repository.TargetManagement;
|
||||
import org.eclipse.hawkbit.repository.TargetTagManagement;
|
||||
import org.eclipse.hawkbit.repository.TargetTypeManagement;
|
||||
import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
|
||||
import org.eclipse.hawkbit.repository.model.Action;
|
||||
import org.eclipse.hawkbit.repository.model.Action.ActionType;
|
||||
@@ -144,6 +145,9 @@ public abstract class AbstractIntegrationTest {
|
||||
@Autowired
|
||||
protected TargetManagement targetManagement;
|
||||
|
||||
@Autowired
|
||||
protected TargetTypeManagement targetTypeManagement;
|
||||
|
||||
@Autowired
|
||||
protected TargetFilterQueryManagement targetFilterQueryManagement;
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ public class JpaTestRepositoryManagement {
|
||||
return null;
|
||||
});
|
||||
} catch (final Exception e) {
|
||||
LOGGER.error("Error hile delete tenant", e);
|
||||
LOGGER.error("Error while delete tenant", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -37,8 +37,10 @@ import org.eclipse.hawkbit.repository.SoftwareModuleManagement;
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleTypeManagement;
|
||||
import org.eclipse.hawkbit.repository.TargetManagement;
|
||||
import org.eclipse.hawkbit.repository.TargetTagManagement;
|
||||
import org.eclipse.hawkbit.repository.TargetTypeManagement;
|
||||
import org.eclipse.hawkbit.repository.builder.TagCreate;
|
||||
import org.eclipse.hawkbit.repository.builder.TargetCreate;
|
||||
import org.eclipse.hawkbit.repository.builder.TargetTypeCreate;
|
||||
import org.eclipse.hawkbit.repository.model.Action;
|
||||
import org.eclipse.hawkbit.repository.model.Action.Status;
|
||||
import org.eclipse.hawkbit.repository.model.ActionStatus;
|
||||
@@ -61,6 +63,7 @@ import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.repository.model.TargetTag;
|
||||
import org.eclipse.hawkbit.repository.model.TargetType;
|
||||
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
@@ -123,6 +126,8 @@ public class TestdataFactory {
|
||||
*/
|
||||
public static final String SM_TYPE_APP = "application";
|
||||
|
||||
public static final String DEFAULT_COLOUR = "#000000";
|
||||
|
||||
@Autowired
|
||||
private ControllerManagement controllerManagament;
|
||||
|
||||
@@ -141,6 +146,9 @@ public class TestdataFactory {
|
||||
@Autowired
|
||||
private TargetManagement targetManagement;
|
||||
|
||||
@Autowired
|
||||
private TargetTypeManagement targetTypeManagement;
|
||||
|
||||
@Autowired
|
||||
private DeploymentManagement deploymentManagement;
|
||||
|
||||
@@ -638,6 +646,22 @@ public class TestdataFactory {
|
||||
return target;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param controllerId
|
||||
* of the target
|
||||
* @param targetName
|
||||
* name of the target
|
||||
* @param targetTypeId
|
||||
* target type id
|
||||
* @return persisted {@link Target}
|
||||
*/
|
||||
public Target createTarget(final String controllerId, final String targetName, final Long targetTypeId) {
|
||||
final Target target = targetManagement
|
||||
.create(entityFactory.target().create().controllerId(controllerId).name(targetName).targetType(targetTypeId));
|
||||
assertTargetProperlyCreated(target);
|
||||
return target;
|
||||
}
|
||||
|
||||
private void assertTargetProperlyCreated(final Target target) {
|
||||
assertThat(target.getCreatedBy()).isNotNull();
|
||||
assertThat(target.getCreatedAt()).isNotNull();
|
||||
@@ -1160,4 +1184,54 @@ public class TestdataFactory {
|
||||
rolloutManagement.handleRollouts();
|
||||
return newRollout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds {@link TargetType} in repository with given
|
||||
* {@link TargetType#getName()} or creates if it does not exist yet.
|
||||
* No ds types are assigned on creation.
|
||||
*
|
||||
* @param targetTypeName
|
||||
* {@link TargetType#getName()}
|
||||
*
|
||||
* @return persisted {@link TargetType}
|
||||
*/
|
||||
public TargetType findOrCreateTargetType(final String targetTypeName) {
|
||||
return targetTypeManagement.getByName(targetTypeName)
|
||||
.orElseGet(() -> targetTypeManagement.create(entityFactory.targetType().create()
|
||||
.name(targetTypeName).description(targetTypeName + " description").colour(DEFAULT_COLOUR)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates {@link TargetType} in repository with given
|
||||
* {@link TargetType#getName()}. Compatible distribution set types are assigned on creation
|
||||
*
|
||||
* @param targetTypeName
|
||||
* {@link TargetType#getName()}
|
||||
*
|
||||
* @return persisted {@link TargetType}
|
||||
*/
|
||||
public TargetType createTargetType(final String targetTypeName, List<DistributionSetType> compatibleDsTypes) {
|
||||
return targetTypeManagement.create(entityFactory.targetType().create()
|
||||
.name(targetTypeName).description(targetTypeName + " description").colour(DEFAULT_COLOUR)
|
||||
.compatible(compatibleDsTypes.stream().map(DistributionSetType::getId).collect(Collectors.toList())));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates {@link TargetType} in repository with given
|
||||
* {@link TargetType#getName()}. No ds types are assigned on creation.
|
||||
*
|
||||
* @param targetTypePrefix
|
||||
* {@link TargetType#getName()}
|
||||
*
|
||||
* @return persisted {@link TargetType}
|
||||
*/
|
||||
public List<TargetType> createTargetTypes(final String targetTypePrefix, int count) {
|
||||
final List<TargetTypeCreate> result = Lists.newArrayListWithExpectedSize(count);
|
||||
for (int i = 0; i < count; i++) {
|
||||
result.add(entityFactory.targetType().create().name(targetTypePrefix + i).description(targetTypePrefix + " description")
|
||||
.colour(DEFAULT_COLOUR));
|
||||
}
|
||||
return targetTypeManagement.create(result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user