Skip to content

Commit b7ba2e6

Browse files
committed
[2758]: Add test for JpaTargetManagment - findByTargetFilterQueryAndNonDSAndCompatibleAndUpdatable
Signed-off-by: Avgustin Marinov <[email protected]>
1 parent 98b4fdc commit b7ba2e6

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetManagementSearchTest.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import org.eclipse.hawkbit.repository.DistributionSetManagement;
1919
import org.eclipse.hawkbit.repository.TargetFilterQueryManagement;
2020
import org.eclipse.hawkbit.repository.jpa.AbstractJpaIntegrationTest;
21+
import org.eclipse.hawkbit.repository.jpa.Jpa;
2122
import org.eclipse.hawkbit.repository.model.Action.ActionStatusCreate;
2223
import org.eclipse.hawkbit.repository.model.Action.Status;
2324
import org.eclipse.hawkbit.repository.model.DistributionSet;
@@ -149,4 +150,30 @@ void shouldNotFindTargetsIncompatibleWithDS() {
149150
.containsExactlyInAnyOrderElementsOf(testTargets).as("does not contain incompatible targets")
150151
.doesNotContainAnyElementsOf(targetsWithIncompatibleType);
151152
}
153+
154+
@Test
155+
void shouldFindTargetsWithoutTypeByTypeIdNot() {
156+
final DistributionSet testDs = testdataFactory.createDistributionSet();
157+
final TargetType targetType = testdataFactory.createTargetType("testType", Set.of(testDs.getType()));
158+
final TargetType targetType2 = testdataFactory.createTargetType("testType_other", Set.of(testDs.getType()));
159+
final TargetFilterQuery tfq = targetFilterQueryManagement
160+
.create(TargetFilterQueryManagement.Create.builder()
161+
.name("test-not-filter").query("type.id=not=" + targetType2.getId()).build());
162+
final List<Target> targets = testdataFactory.createTargets(20, "withOutType");
163+
final List<Target> targetWithCompatibleTypes = testdataFactory.createTargetsWithType(20, "compatible", targetType);
164+
165+
final List<Target> result = targetManagement
166+
.findByTargetFilterQueryAndNonDSAndCompatibleAndUpdatable(testDs.getId(), tfq.getQuery(), PAGE).getContent();
167+
168+
// EclipseLink has problems with tenancy - https://github.com/eclipse-hawkbit/hawkbit/issues/2758
169+
if (Jpa.JPA_VENDOR == Jpa.JpaVendor.ECLIPSELINK) {
170+
assertThat(result)
171+
.as("count of targets").hasSize(targetWithCompatibleTypes.size())
172+
.as("contains only targets with type").containsAll(targetWithCompatibleTypes).doesNotContainAnyElementsOf(targets);
173+
} else {
174+
assertThat(result)
175+
.as("count of targets").hasSize(targets.size() + targetWithCompatibleTypes.size())
176+
.as("contains all targets").containsAll(targetWithCompatibleTypes).containsAll(targets);
177+
}
178+
}
152179
}

0 commit comments

Comments
 (0)