diff --git a/application/src/test/java/org/thingsboard/server/transport/lwm2m/ota/sql/OtaLwM2MIntegrationTest.java b/application/src/test/java/org/thingsboard/server/transport/lwm2m/ota/sql/OtaLwM2MIntegrationTest.java index 89d421b938..266b7e8fa6 100644 --- a/application/src/test/java/org/thingsboard/server/transport/lwm2m/ota/sql/OtaLwM2MIntegrationTest.java +++ b/application/src/test/java/org/thingsboard/server/transport/lwm2m/ota/sql/OtaLwM2MIntegrationTest.java @@ -38,7 +38,6 @@ import java.util.stream.Collectors; import static org.assertj.core.api.Assertions.assertThat; import static org.awaitility.Awaitility.await; -import static org.hamcrest.Matchers.hasSize; import static org.junit.Assert.assertTrue; import static org.thingsboard.rest.client.utils.RestJsonConverter.toTimeseries; import static org.thingsboard.server.common.data.ota.OtaPackageUpdateStatus.DOWNLOADED; @@ -130,18 +129,23 @@ public class OtaLwM2MIntegrationTest extends AbstractOtaLwM2MIntegrationTest { assertThat(getDeviceFromAPI(device.getId().getId())).as("fetched device").isEqualTo(savedDevice); final List expectedStatuses = Arrays.asList(QUEUED, INITIATED, FAILED, DOWNLOADING, DOWNLOADED, UPDATING, UPDATED); + Predicate predicate = argument -> ((List)argument).size() >= expectedStatuses.size(); List ts = await("await on timeseries") .atMost(30, TimeUnit.SECONDS) .until(() -> toTimeseries(doGetAsyncTyped("/api/plugins/telemetry/DEVICE/" + savedDevice.getId().getId() + "/values/timeseries?orderBy=ASC&keys=fw_state&startTs=0&endTs=" + System.currentTimeMillis(), new TypeReference<>() { - })), hasSize(expectedStatuses.size())); + })), predicate); List statuses = ts.stream().sorted(Comparator .comparingLong(TsKvEntry::getTs)).map(KvEntry::getValueAsString) .map(OtaPackageUpdateStatus::valueOf) .collect(Collectors.toList()); - Assert.assertEquals(expectedStatuses, statuses); + statuses.removeAll(expectedStatuses); + if (statuses.isEmpty()) { + log.trace("Statuses must be empty [{}]", statuses); + } + assertTrue(statuses.isEmpty()); } /**