diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/rsql/AbstractFieldNameRSQLVisitor.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/rsql/AbstractFieldNameRSQLVisitor.java
index 8880499fd..684a4c46e 100644
--- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/rsql/AbstractFieldNameRSQLVisitor.java
+++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/rsql/AbstractFieldNameRSQLVisitor.java
@@ -60,7 +60,7 @@ public abstract class AbstractFieldNameRSQLVisitor & FieldName
for (int i = 1; i < graph.length; i++) {
- final String propertyField = graph[i];
+ final String propertyField = getFormattedSubEntityAttribute(propertyEnum ,graph[i]);
fieldNameBuilder.append(FieldNameProvider.SUB_ATTRIBUTE_SEPARATOR).append(propertyField);
// the key of map is not in the graph
@@ -110,6 +110,11 @@ public abstract class AbstractFieldNameRSQLVisitor & FieldName
node.getSelector(), getExpectedFieldList()), rootException);
}
+ private String getFormattedSubEntityAttribute(final A propertyEnum, final String propertyField) {
+ return propertyEnum.getSubEntityAttributes().stream().filter(attr -> attr.equalsIgnoreCase(propertyField))
+ .findFirst().orElse(propertyField);
+ }
+
private List getExpectedFieldList() {
final List expectedFieldList = Arrays.stream(fieldNameProvider.getEnumConstants())
.filter(enumField -> enumField.getSubEntityAttributes().isEmpty()).map(enumField -> {
diff --git a/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/TestdataFactory.java b/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/TestdataFactory.java
index 77efb3507..ec29be426 100644
--- a/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/TestdataFactory.java
+++ b/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/TestdataFactory.java
@@ -647,7 +647,14 @@ public class TestdataFactory {
*/
public Target createTarget(final String controllerId, final String targetName) {
final Target target = targetManagement
- .create(entityFactory.target().create().controllerId(controllerId).name(targetName));
+ .create(entityFactory.target().create().controllerId(controllerId).name(targetName));
+ assertTargetProperlyCreated(target);
+ return target;
+ }
+
+ public Target createTarget(final String controllerId, final String targetName, final String address) {
+ final Target target = targetManagement
+ .create(entityFactory.target().create().controllerId(controllerId).name(targetName).address(address));
assertTargetProperlyCreated(target);
return target;
}
diff --git a/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtActionResourceTest.java b/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtActionResourceTest.java
index 0641b14cf..e78e52a67 100644
--- a/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtActionResourceTest.java
+++ b/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtActionResourceTest.java
@@ -40,6 +40,7 @@ import org.junit.jupiter.api.Test;
import io.qameta.allure.Description;
import io.qameta.allure.Feature;
+import io.qameta.allure.Step;
import io.qameta.allure.Story;
/**
@@ -228,17 +229,29 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
@Test
@Description("Verifies that actions can be filtered based on target fields.")
- void filterActionsByTarget() throws Exception {
+ void filterActionsByTargetProperties() throws Exception {
// prepare test
- final Target target = testdataFactory.createTarget("knownTargetId");
+ final Target target = testdataFactory.createTarget("knownTargetId", "knownTargetName", "http://0.0.0.0");
final DistributionSet ds = testdataFactory.createDistributionSet("");
assignDistributionSet(ds, Collections.singletonList(target));
- final String rsqlTargetName = "target.name==knownTargetId";
+ final String rsqlTargetControllerId = "target.controllerId==knownTargetId";
+ final String rsqlTargetName = "target.name==knownTargetName";
+ final String rsqlTargetUpdateStatus = "target.updateStatus==pending";
+ final String rsqlTargetAddress = "target.address==http://0.0.0.0";
+ verifyResultsByTargetPropertyFilter(target, ds, rsqlTargetControllerId);
+ verifyResultsByTargetPropertyFilter(target, ds, rsqlTargetName);
+ verifyResultsByTargetPropertyFilter(target, ds, rsqlTargetUpdateStatus);
+ verifyResultsByTargetPropertyFilter(target, ds, rsqlTargetAddress);
+ }
+
+ @Step
+ private void verifyResultsByTargetPropertyFilter(final Target target, final DistributionSet ds,
+ final String rsqlTargetFilter) throws Exception {
// pending status one result
- mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlTargetName)
+ mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlTargetFilter)
.param(MgmtRestConstants.REQUEST_PARAMETER_REPRESENTATION_MODE, MgmtRepresentationMode.FULL.toString()))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()).andExpect(jsonPath("total", equalTo(1)))
.andExpect(jsonPath("size", equalTo(1)))
@@ -403,17 +416,15 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
final Long actionId = actions.get(0).getId();
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "/" + actionId))
- .andDo(MockMvcResultPrinter.print())
- .andExpect(status().isOk())
- .andExpect(jsonPath(JSON_PATH_ACTION_ID, equalTo(actionId.intValue())));
+ .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
+ .andExpect(jsonPath(JSON_PATH_ACTION_ID, equalTo(actionId.intValue())));
}
@Test
@Description("Verifies that NOT_FOUND is returned when there is no such action.")
void requestActionThatDoesNotExistsLeadsToNotFound() throws Exception {
- mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "/" + 101))
- .andDo(MockMvcResultPrinter.print())
- .andExpect(status().isNotFound());
+ mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "/" + 101)).andDo(MockMvcResultPrinter.print())
+ .andExpect(status().isNotFound());
}
private List generateTargetWithTwoUpdatesWithOneOverride(final String knownTargetId) {