Remove allure (phase2) (#2483)
Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -12,23 +12,22 @@ package org.eclipse.hawkbit.repository;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
|
||||
import io.qameta.allure.Description;
|
||||
import io.qameta.allure.Feature;
|
||||
import io.qameta.allure.Story;
|
||||
import org.eclipse.hawkbit.repository.exception.ArtifactEncryptionUnsupportedException;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Test class to verify that no {@link ArtifactEncryptionService} required beans
|
||||
* are loaded and therefore the encryption support is not given.
|
||||
* <p/>
|
||||
* Feature: Unit Tests - Repository<br/>
|
||||
* Story: Artifact Encryption Service
|
||||
*/
|
||||
@Feature("Unit Tests - Repository")
|
||||
@Story("Artifact Encryption Service")
|
||||
class ArtifactEncryptionServiceTest {
|
||||
|
||||
@Test
|
||||
@Description("Verify that no artifact encryption support is given")
|
||||
void verifyNoArtifactEncryptionSupport() {
|
||||
/**
|
||||
* Verify that no artifact encryption support is given
|
||||
*/
|
||||
@Test void verifyNoArtifactEncryptionSupport() {
|
||||
final ArtifactEncryptionService artifactEncryptionService = ArtifactEncryptionService.getInstance();
|
||||
|
||||
assertThat(artifactEncryptionService.isEncryptionSupported()).isFalse();
|
||||
|
||||
@@ -16,51 +16,55 @@ import java.time.Duration;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
import com.cronutils.model.Cron;
|
||||
import io.qameta.allure.Description;
|
||||
import io.qameta.allure.Feature;
|
||||
import io.qameta.allure.Story;
|
||||
import org.eclipse.hawkbit.repository.exception.InvalidMaintenanceScheduleException;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@Feature("Unit Tests - Repository")
|
||||
@Story("Maintenance Schedule Utility")
|
||||
/**
|
||||
* Feature: Unit Tests - Repository<br/>
|
||||
* Story: Maintenance Schedule Utility
|
||||
*/
|
||||
class MaintenanceScheduleHelperTest {
|
||||
|
||||
@Test
|
||||
@Description("Verifies that the Cron object is returned for valid cron expression")
|
||||
void getCronFromExpressionValid() {
|
||||
/**
|
||||
* Verifies that the Cron object is returned for valid cron expression
|
||||
*/
|
||||
@Test void getCronFromExpressionValid() {
|
||||
final String validCron = "0 0 0 ? * 6"; // at 00:00 every Saturday
|
||||
assertThat(MaintenanceScheduleHelper.getCronFromExpression(validCron)).isNotNull().isInstanceOf(Cron.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Verifies that the Duration object is returned for valid duration format (hh:mm or hh:mm:ss)")
|
||||
void convertToISODurationValid() {
|
||||
/**
|
||||
* Verifies that the Duration object is returned for valid duration format (hh:mm or hh:mm:ss)
|
||||
*/
|
||||
@Test void convertToISODurationValid() {
|
||||
final String duration = "00:10";
|
||||
assertThat(MaintenanceScheduleHelper.convertToISODuration(duration)).isNotNull().isInstanceOf(Duration.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Verifies that the InvalidMaintenanceScheduleException is thrown for invalid duration format")
|
||||
void validateDurationInvalid() {
|
||||
/**
|
||||
* Verifies that the InvalidMaintenanceScheduleException is thrown for invalid duration format
|
||||
*/
|
||||
@Test void validateDurationInvalid() {
|
||||
final String duration = "10";
|
||||
assertThatThrownBy(() -> MaintenanceScheduleHelper.validateDuration(duration))
|
||||
.isInstanceOf(InvalidMaintenanceScheduleException.class).hasMessage("Provided duration is not valid")
|
||||
.extracting("durationErrorIndex").isEqualTo(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Verifies that the InvalidMaintenanceScheduleException is thrown for invalid cron expression")
|
||||
void validateCronScheduleInvalid() {
|
||||
/**
|
||||
* Verifies that the InvalidMaintenanceScheduleException is thrown for invalid cron expression
|
||||
*/
|
||||
@Test void validateCronScheduleInvalid() {
|
||||
final String invalidCron = "0 0 0 * * 6";
|
||||
assertThatThrownBy(() -> MaintenanceScheduleHelper.validateCronSchedule(invalidCron))
|
||||
.isInstanceOf(InvalidMaintenanceScheduleException.class)
|
||||
.hasMessageContaining("Both, a day-of-week AND a day-of-month parameter, are not supported");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Verifies that there is a maintenance window available for correct schedule, duration and timezone")
|
||||
void getNextMaintenanceWindowValid() {
|
||||
/**
|
||||
* Verifies that there is a maintenance window available for correct schedule, duration and timezone
|
||||
*/
|
||||
@Test void getNextMaintenanceWindowValid() {
|
||||
final ZonedDateTime currentTime = ZonedDateTime.now();
|
||||
final String cronSchedule = String.format("0 %d %d %d %d ? %d", currentTime.getMinute(), currentTime.getHour(),
|
||||
currentTime.getDayOfMonth(), currentTime.getMonthValue(), currentTime.getYear());
|
||||
@@ -69,18 +73,20 @@ class MaintenanceScheduleHelperTest {
|
||||
assertThat(MaintenanceScheduleHelper.getNextMaintenanceWindow(cronSchedule, duration, timezone)).isPresent();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Verifies the maintenance schedule when only one required field is present")
|
||||
void validateMaintenanceScheduleAtLeastOneNotEmpty() {
|
||||
/**
|
||||
* Verifies the maintenance schedule when only one required field is present
|
||||
*/
|
||||
@Test void validateMaintenanceScheduleAtLeastOneNotEmpty() {
|
||||
final String duration = "00:10";
|
||||
assertThatThrownBy(() -> MaintenanceScheduleHelper.validateMaintenanceSchedule(null, duration, null))
|
||||
.isInstanceOf(InvalidMaintenanceScheduleException.class)
|
||||
.hasMessage("All of schedule, duration and timezone should either be null or non empty.");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Verifies that there is no valid maintenance window available, scheduled before current time")
|
||||
void validateMaintenanceScheduleBeforeCurrentTime() {
|
||||
/**
|
||||
* Verifies that there is no valid maintenance window available, scheduled before current time
|
||||
*/
|
||||
@Test void validateMaintenanceScheduleBeforeCurrentTime() {
|
||||
ZonedDateTime currentTime = ZonedDateTime.now();
|
||||
currentTime = currentTime.plusMinutes(-30);
|
||||
final String cronSchedule = String.format("0 %d %d %d %d ? %d", currentTime.getMinute(), currentTime.getHour(),
|
||||
|
||||
@@ -11,23 +11,23 @@ package org.eclipse.hawkbit.repository;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import io.qameta.allure.Description;
|
||||
import io.qameta.allure.Feature;
|
||||
import io.qameta.allure.Story;
|
||||
import org.eclipse.hawkbit.repository.RegexCharacterCollection.RegexChar;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@Feature("Unit Tests - Repository")
|
||||
@Story("Regular expression helper")
|
||||
/**
|
||||
* Feature: Unit Tests - Repository<br/>
|
||||
* Story: Regular expression helper
|
||||
*/
|
||||
class RegexCharTest {
|
||||
|
||||
private static final int INDEX_FIRST_PRINTABLE_ASCII_CHAR = 32;
|
||||
private static final int INDEX_LAST_PRINTABLE_ASCII_CHAR = 127;
|
||||
private static final String TEST_STRING = getPrintableAsciiCharacters();
|
||||
|
||||
@Test
|
||||
@Description("Verifies every RegexChar can be used to exclusively find the desired characters in a String.")
|
||||
void allRegexCharsOnlyFindExpectedChars() {
|
||||
/**
|
||||
* Verifies every RegexChar can be used to exclusively find the desired characters in a String.
|
||||
*/
|
||||
@Test void allRegexCharsOnlyFindExpectedChars() {
|
||||
for (final RegexChar character : RegexChar.values()) {
|
||||
switch (character) {
|
||||
case DIGITS:
|
||||
@@ -49,9 +49,10 @@ class RegexCharTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Verifies that combinations of RegexChars can be used to find the desired characters in a String.")
|
||||
void combinedRegexCharsFindExpectedChars() {
|
||||
/**
|
||||
* Verifies that combinations of RegexChars can be used to find the desired characters in a String.
|
||||
*/
|
||||
@Test void combinedRegexCharsFindExpectedChars() {
|
||||
final RegexCharacterCollection greaterAndLessThan = new RegexCharacterCollection(RegexChar.GREATER_THAN,
|
||||
RegexChar.LESS_THAN);
|
||||
final RegexCharacterCollection equalsAndQuestionMark = new RegexCharacterCollection(RegexChar.EQUALS_SYMBOL,
|
||||
|
||||
@@ -20,22 +20,22 @@ import java.util.Set;
|
||||
import io.github.classgraph.ClassGraph;
|
||||
import io.github.classgraph.ClassInfo;
|
||||
import io.github.classgraph.ScanResult;
|
||||
import io.qameta.allure.Description;
|
||||
import io.qameta.allure.Feature;
|
||||
import io.qameta.allure.Story;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
||||
@Feature("Unit Tests - Repository")
|
||||
@Story("Security Test")
|
||||
/**
|
||||
* Feature: Unit Tests - Repository<br/>
|
||||
* Story: Security Test
|
||||
*/
|
||||
class RepositoryManagementMethodPreAuthorizeAnnotatedTest {
|
||||
|
||||
// if some methods are to be excluded
|
||||
private static final Set<Method> METHOD_SECURITY_EXCLUSION = new HashSet<>();
|
||||
|
||||
@Test
|
||||
@Description("Verifies that repository methods are @PreAuthorize annotated")
|
||||
void repositoryManagementMethodsArePreAuthorizedAnnotated() {
|
||||
/**
|
||||
* Verifies that repository methods are @PreAuthorize annotated
|
||||
*/
|
||||
@Test void repositoryManagementMethodsArePreAuthorizedAnnotated() {
|
||||
final String packageName = getClass().getPackage().getName();
|
||||
try (final ScanResult scanResult = new ClassGraph().acceptPackages(packageName).scan()) {
|
||||
final List<? extends Class<?>> matchingClasses = scanResult.getAllClasses()
|
||||
|
||||
@@ -15,13 +15,12 @@ import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import io.qameta.allure.Description;
|
||||
import io.qameta.allure.Feature;
|
||||
import io.qameta.allure.Story;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@Feature("Component Tests - TotalTargetCountStatus")
|
||||
@Story("TotalTargetCountStatus should correctly present finished DOWNLOAD_ONLY actions")
|
||||
/**
|
||||
* Feature: Component Tests - TotalTargetCountStatus<br/>
|
||||
* Story: TotalTargetCountStatus should correctly present finished DOWNLOAD_ONLY actions
|
||||
*/
|
||||
class TotalTargetCountStatusTest {
|
||||
|
||||
private final List<TotalTargetCountActionStatus> targetCountActionStatuses = Arrays.asList(
|
||||
@@ -36,9 +35,10 @@ class TotalTargetCountStatusTest {
|
||||
new TotalTargetCountActionStatus(Action.Status.CANCELING, 9L),
|
||||
new TotalTargetCountActionStatus(Action.Status.DOWNLOADED, 10L));
|
||||
|
||||
/**
|
||||
* Different Action Statuses should be correctly mapped to the corresponding TotalTargetCountStatus.Status
|
||||
*/
|
||||
@Test
|
||||
@Description("Different Action Statuses should be correctly mapped to the corresponding " +
|
||||
"TotalTargetCountStatus.Status")
|
||||
void shouldCorrectlyMapActionStatuses() {
|
||||
TotalTargetCountStatus status = new TotalTargetCountStatus(targetCountActionStatuses, 55L,
|
||||
Action.ActionType.FORCED);
|
||||
@@ -51,9 +51,11 @@ class TotalTargetCountStatusTest {
|
||||
assertThat(status.getFinishedPercent()).isEqualTo((float) 100 * 3 / 55);
|
||||
}
|
||||
|
||||
/**
|
||||
* When an empty list is passed to the TotalTargetCountStatus, all actions should be displayed as
|
||||
* NOTSTARTED
|
||||
*/
|
||||
@Test
|
||||
@Description("When an empty list is passed to the TotalTargetCountStatus, all actions should be displayed as " +
|
||||
"NOTSTARTED")
|
||||
void shouldCorrectlyMapActionStatusesToNotStarted() {
|
||||
TotalTargetCountStatus status = new TotalTargetCountStatus(Collections.emptyList(), 55L,
|
||||
Action.ActionType.FORCED);
|
||||
@@ -66,9 +68,10 @@ class TotalTargetCountStatusTest {
|
||||
assertThat(status.getFinishedPercent()).isZero();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("DownloadOnly actions should be displayed as FINISHED when they have ActionStatus.DOWNLOADED")
|
||||
void shouldCorrectlyMapActionStatusesInDownloadOnlyCase() {
|
||||
/**
|
||||
* DownloadOnly actions should be displayed as FINISHED when they have ActionStatus.DOWNLOADED
|
||||
*/
|
||||
@Test void shouldCorrectlyMapActionStatusesInDownloadOnlyCase() {
|
||||
TotalTargetCountStatus status = new TotalTargetCountStatus(targetCountActionStatuses, 55L,
|
||||
Action.ActionType.DOWNLOAD_ONLY);
|
||||
assertThat(status.getTotalTargetCountByStatus(TotalTargetCountStatus.Status.SCHEDULED)).isEqualTo(1L);
|
||||
|
||||
Reference in New Issue
Block a user