Add JpaRolloutGroup converter test (#2048)

Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2024-11-16 11:42:37 +02:00
committed by GitHub
parent 20b1c61c13
commit 4545849548

View File

@@ -27,6 +27,7 @@ import org.eclipse.hawkbit.repository.event.remote.entity.SoftwareModuleCreatedE
import org.eclipse.hawkbit.repository.event.remote.entity.SoftwareModuleUpdatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.SoftwareModuleUpdatedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.TargetCreatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.TargetCreatedEvent;
import org.eclipse.hawkbit.repository.jpa.AbstractJpaIntegrationTest; import org.eclipse.hawkbit.repository.jpa.AbstractJpaIntegrationTest;
import org.eclipse.hawkbit.repository.jpa.model.JpaRolloutGroup;
import org.eclipse.hawkbit.repository.model.Action; import org.eclipse.hawkbit.repository.model.Action;
import org.eclipse.hawkbit.repository.model.Action.Status; import org.eclipse.hawkbit.repository.model.Action.Status;
import org.eclipse.hawkbit.repository.model.Rollout; import org.eclipse.hawkbit.repository.model.Rollout;
@@ -56,8 +57,8 @@ class RolloutGroupManagementTest extends AbstractJpaIntegrationTest {
} }
@Test @Test
@Description("Verifies that management queries react as specfied on calls for non existing entities " @Description("Verifies that management queries react as specified on calls for non existing entities " +
+ " by means of throwing EntityNotFoundException.") " by means of throwing EntityNotFoundException.")
@ExpectEvents({ @Expect(type = RolloutDeletedEvent.class, count = 0), @ExpectEvents({ @Expect(type = RolloutDeletedEvent.class, count = 0),
@Expect(type = RolloutGroupCreatedEvent.class, count = 5), @Expect(type = RolloutGroupCreatedEvent.class, count = 5),
@Expect(type = RolloutGroupUpdatedEvent.class, count = 5), @Expect(type = RolloutGroupUpdatedEvent.class, count = 5),
@@ -217,6 +218,20 @@ class RolloutGroupManagementTest extends AbstractJpaIntegrationTest {
Status.RUNNING, 100); Status.RUNNING, 100);
} }
@Test
@Description("Tests the rollout status mapping.")
void testRolloutGroupStatusConvert() {
final long id = rolloutGroupRepository.findByRolloutId(
testdataFactory.createAndStartRollout(1, 0, 1, "100", "80").getId(), PAGE).getContent()
.get(0).getId();
for (final RolloutGroup.RolloutGroupStatus status : RolloutGroup.RolloutGroupStatus.values()) {
final JpaRolloutGroup rolloutGroup = ((JpaRolloutGroup) rolloutGroupManagement.get(id).orElseThrow());
rolloutGroup.setStatus(status);
rolloutGroupRepository.save(rolloutGroup);
assertThat( rolloutGroupManagement.get(id).orElseThrow().getStatus()).isEqualTo(status);
}
}
private void assertSortedListOfActionStatus(final List<TargetWithActionStatus> targetsWithActionStatus, private void assertSortedListOfActionStatus(final List<TargetWithActionStatus> targetsWithActionStatus,
final Target first, final Integer firstStatusCode, final Target last, final Integer lastStatusCode) { final Target first, final Integer firstStatusCode, final Target last, final Integer lastStatusCode) {
assertTargetAndActionStatusCode(CollectionUtils.firstElement(targetsWithActionStatus), first, firstStatusCode); assertTargetAndActionStatusCode(CollectionUtils.firstElement(targetsWithActionStatus), first, firstStatusCode);