Fix sonar findings: Type constants access (#1983)
Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -26,5 +26,4 @@ public interface DistributionSetBuilder {
|
||||
* @return builder instance
|
||||
*/
|
||||
DistributionSetCreate create();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||
import org.eclipse.hawkbit.repository.model.NamedEntity;
|
||||
import org.eclipse.hawkbit.repository.model.NamedVersionedEntity;
|
||||
import org.eclipse.hawkbit.repository.model.Type;
|
||||
|
||||
/**
|
||||
* Builder to create a new {@link DistributionSet} entry. Defines all fields
|
||||
@@ -50,7 +51,7 @@ public interface DistributionSetCreate {
|
||||
* @param typeKey for {@link DistributionSet#getType()}
|
||||
* @return updated builder instance
|
||||
*/
|
||||
DistributionSetCreate type(@Size(min = 1, max = DistributionSetType.KEY_MAX_SIZE) @NotNull String typeKey);
|
||||
DistributionSetCreate type(@Size(min = 1, max = Type.KEY_MAX_SIZE) @NotNull String typeKey);
|
||||
|
||||
/**
|
||||
* @param type for {@link DistributionSet#getType()}
|
||||
@@ -76,4 +77,4 @@ public interface DistributionSetCreate {
|
||||
* @return peek on current state of {@link DistributionSet} in the builder
|
||||
*/
|
||||
DistributionSet build();
|
||||
}
|
||||
}
|
||||
@@ -26,5 +26,4 @@ public interface DistributionSetTypeBuilder {
|
||||
* @return builder instance
|
||||
*/
|
||||
DistributionSetTypeCreate create();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -9,8 +9,8 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.builder;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Optional;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
@@ -20,6 +20,7 @@ import org.eclipse.hawkbit.repository.model.BaseEntity;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||
import org.eclipse.hawkbit.repository.model.NamedEntity;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||
import org.eclipse.hawkbit.repository.model.Type;
|
||||
|
||||
/**
|
||||
* Builder to create a new {@link DistributionSetType} entry. Defines all fields
|
||||
@@ -32,7 +33,7 @@ public interface DistributionSetTypeCreate {
|
||||
* @param key for {@link DistributionSetType#getKey()}
|
||||
* @return updated builder instance
|
||||
*/
|
||||
DistributionSetTypeCreate key(@Size(min = 1, max = DistributionSetType.KEY_MAX_SIZE) @NotNull String key);
|
||||
DistributionSetTypeCreate key(@Size(min = 1, max = Type.KEY_MAX_SIZE) @NotNull String key);
|
||||
|
||||
/**
|
||||
* @param name for {@link DistributionSetType#getName()}
|
||||
@@ -50,7 +51,7 @@ public interface DistributionSetTypeCreate {
|
||||
* @param colour for {@link DistributionSetType#getColour()}
|
||||
* @return updated builder instance
|
||||
*/
|
||||
DistributionSetTypeCreate colour(@Size(max = DistributionSetType.COLOUR_MAX_SIZE) String colour);
|
||||
DistributionSetTypeCreate colour(@Size(max = Type.COLOUR_MAX_SIZE) String colour);
|
||||
|
||||
/**
|
||||
* @param mandatory for {@link DistributionSetType#getMandatoryModuleTypes()}
|
||||
@@ -63,7 +64,7 @@ public interface DistributionSetTypeCreate {
|
||||
* @return updated builder instance
|
||||
*/
|
||||
default DistributionSetTypeCreate mandatory(final Long mandatory) {
|
||||
return mandatory(Arrays.asList(mandatory));
|
||||
return mandatory(Collections.singletonList(mandatory));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,7 +86,7 @@ public interface DistributionSetTypeCreate {
|
||||
* @return updated builder instance
|
||||
*/
|
||||
default DistributionSetTypeCreate optional(final Long optional) {
|
||||
return optional(Arrays.asList(optional));
|
||||
return optional(Collections.singletonList(optional));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -97,8 +98,7 @@ public interface DistributionSetTypeCreate {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return peek on current state of {@link DistributionSetType} in the
|
||||
* builder
|
||||
* @return peek on current state of {@link DistributionSetType} in the builder
|
||||
*/
|
||||
DistributionSetType build();
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import jakarta.validation.constraints.Size;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||
import org.eclipse.hawkbit.repository.model.NamedEntity;
|
||||
import org.eclipse.hawkbit.repository.model.Type;
|
||||
|
||||
/**
|
||||
* Builder to update an existing {@link DistributionSetType} entry. Defines all
|
||||
@@ -32,7 +33,7 @@ public interface DistributionSetTypeUpdate {
|
||||
* @param colour for {@link DistributionSetType#getColour()}
|
||||
* @return updated builder instance
|
||||
*/
|
||||
DistributionSetTypeUpdate colour(@Size(max = DistributionSetType.COLOUR_MAX_SIZE) String colour);
|
||||
DistributionSetTypeUpdate colour(@Size(max = Type.COLOUR_MAX_SIZE) String colour);
|
||||
|
||||
/**
|
||||
* @param mandatory for {@link DistributionSetType#getMandatoryModuleTypes()}
|
||||
@@ -45,4 +46,4 @@ public interface DistributionSetTypeUpdate {
|
||||
* @return updated builder instance
|
||||
*/
|
||||
DistributionSetTypeUpdate optional(Collection<Long> optional);
|
||||
}
|
||||
}
|
||||
@@ -18,8 +18,7 @@ import org.eclipse.hawkbit.repository.model.NamedEntity;
|
||||
import org.eclipse.hawkbit.repository.model.NamedVersionedEntity;
|
||||
|
||||
/**
|
||||
* Builder to update an existing {@link DistributionSet} entry. Defines all
|
||||
* fields that can be updated.
|
||||
* Builder to update an existing {@link DistributionSet} entry. Defines all fields that can be updated.
|
||||
*/
|
||||
public interface DistributionSetUpdate {
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ import org.eclipse.hawkbit.repository.model.NamedEntity;
|
||||
import org.eclipse.hawkbit.repository.model.NamedVersionedEntity;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||
import org.eclipse.hawkbit.repository.model.Type;
|
||||
|
||||
/**
|
||||
* Builder to create a new {@link SoftwareModule} entry. Defines all fields that
|
||||
@@ -55,7 +56,7 @@ public interface SoftwareModuleCreate {
|
||||
* @param typeKey for {@link SoftwareModule#getType()}
|
||||
* @return updated builder instance
|
||||
*/
|
||||
SoftwareModuleCreate type(@Size(min = 1, max = SoftwareModuleType.KEY_MAX_SIZE) @NotNull String typeKey);
|
||||
SoftwareModuleCreate type(@Size(min = 1, max = Type.KEY_MAX_SIZE) @NotNull String typeKey);
|
||||
|
||||
/**
|
||||
* @param type for {@link SoftwareModule#getType()}
|
||||
|
||||
@@ -15,6 +15,7 @@ import jakarta.validation.constraints.Size;
|
||||
import org.eclipse.hawkbit.repository.model.BaseEntity;
|
||||
import org.eclipse.hawkbit.repository.model.NamedEntity;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||
import org.eclipse.hawkbit.repository.model.Type;
|
||||
|
||||
/**
|
||||
* Builder to create a new {@link SoftwareModuleType} entry. Defines all fields
|
||||
@@ -27,7 +28,7 @@ public interface SoftwareModuleTypeCreate {
|
||||
* @param key for {@link SoftwareModuleType#getKey()}
|
||||
* @return updated builder instance
|
||||
*/
|
||||
SoftwareModuleTypeCreate key(@Size(min = 1, max = SoftwareModuleType.KEY_MAX_SIZE) @NotNull String key);
|
||||
SoftwareModuleTypeCreate key(@Size(min = 1, max = Type.KEY_MAX_SIZE) @NotNull String key);
|
||||
|
||||
/**
|
||||
* @param name for {@link SoftwareModuleType#getName()}
|
||||
@@ -45,7 +46,7 @@ public interface SoftwareModuleTypeCreate {
|
||||
* @param colour for {@link SoftwareModuleType#getColour()}
|
||||
* @return updated builder instance
|
||||
*/
|
||||
SoftwareModuleTypeCreate colour(@Size(max = SoftwareModuleType.COLOUR_MAX_SIZE) String colour);
|
||||
SoftwareModuleTypeCreate colour(@Size(max = Type.COLOUR_MAX_SIZE) String colour);
|
||||
|
||||
/**
|
||||
* @param maxAssignments for {@link SoftwareModuleType#getMaxAssignments()}
|
||||
|
||||
@@ -13,6 +13,7 @@ import jakarta.validation.constraints.Size;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.NamedEntity;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||
import org.eclipse.hawkbit.repository.model.Type;
|
||||
|
||||
/**
|
||||
* Builder to update an existing {@link SoftwareModuleType} entry. Defines all
|
||||
@@ -30,5 +31,5 @@ public interface SoftwareModuleTypeUpdate {
|
||||
* @param colour for {@link SoftwareModuleType#getColour()}
|
||||
* @return updated builder instance
|
||||
*/
|
||||
SoftwareModuleTypeUpdate colour(@Size(max = SoftwareModuleType.COLOUR_MAX_SIZE) String colour);
|
||||
}
|
||||
SoftwareModuleTypeUpdate colour(@Size(max = Type.COLOUR_MAX_SIZE) String colour);
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import jakarta.validation.constraints.Size;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.NamedEntity;
|
||||
import org.eclipse.hawkbit.repository.model.TargetType;
|
||||
import org.eclipse.hawkbit.repository.model.Type;
|
||||
|
||||
/**
|
||||
* Builder to update an existing {@link TargetType} entry. Defines all
|
||||
@@ -30,7 +31,7 @@ public interface TargetTypeUpdate {
|
||||
* @param colour for {@link TargetType#getColour()}
|
||||
* @return updated builder instance
|
||||
*/
|
||||
TargetTypeUpdate colour(@Size(max = TargetType.COLOUR_MAX_SIZE) String colour);
|
||||
TargetTypeUpdate colour(@Size(max = Type.COLOUR_MAX_SIZE) String colour);
|
||||
|
||||
/**
|
||||
* @param name Name
|
||||
|
||||
@@ -10,8 +10,7 @@
|
||||
package org.eclipse.hawkbit.repository.model;
|
||||
|
||||
/**
|
||||
* {@link Type} is an abstract definition for {@link DistributionSetType}s and
|
||||
* {@link SoftwareModuleType}s
|
||||
* {@link Type} is an abstract definition for {@link DistributionSetType}s and {@link SoftwareModuleType}s
|
||||
*/
|
||||
public interface Type extends NamedEntity {
|
||||
|
||||
@@ -31,8 +30,7 @@ public interface Type extends NamedEntity {
|
||||
String getKey();
|
||||
|
||||
/**
|
||||
* @return <code>true</code> if the type is deleted and only kept for
|
||||
* history purposes.
|
||||
* @return <code>true</code> if the type is deleted and only kept for history purposes.
|
||||
*/
|
||||
boolean isDeleted();
|
||||
|
||||
@@ -40,5 +38,4 @@ public interface Type extends NamedEntity {
|
||||
* @return get color code to be used in management UI views.
|
||||
*/
|
||||
String getColour();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -214,7 +214,7 @@ class TargetTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
.as("targetType with too long colour should not be created")
|
||||
.isThrownBy(() -> targetTypeManagement.create(
|
||||
entityFactory.targetType().create().name("a")
|
||||
.colour(RandomStringUtils.randomAlphanumeric(TargetType.COLOUR_MAX_SIZE + 1))));
|
||||
.colour(RandomStringUtils.randomAlphanumeric(Type.COLOUR_MAX_SIZE + 1))));
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("targetType with invalid colour should not be created").isThrownBy(() -> targetTypeManagement
|
||||
@@ -224,7 +224,7 @@ class TargetTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
.as("targetType with too long colour should not be updated")
|
||||
.isThrownBy(() -> targetTypeManagement.update(
|
||||
entityFactory.targetType().update(targetType.getId())
|
||||
.colour(RandomStringUtils.randomAlphanumeric(TargetType.COLOUR_MAX_SIZE + 1))));
|
||||
.colour(RandomStringUtils.randomAlphanumeric(Type.COLOUR_MAX_SIZE + 1))));
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("targetType with invalid colour should not be updated").isThrownBy(() -> targetTypeManagement
|
||||
|
||||
Reference in New Issue
Block a user