fix null pointer exception in rsql target field validation test (#1172)
Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch.io>
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
package org.eclipse.hawkbit.repository.jpa.rsql;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -234,6 +235,32 @@ public class RSQLTargetFieldTest extends AbstractJpaIntegrationTest {
|
||||
+ TargetFields.CONTROLLERID.name() + "!=targetId1235", 4);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Testing allowed RSQL keys based on TargetFields definition")
|
||||
public void rsqlValidTargetFields() {
|
||||
final String rsql1 = "ID == '0123' and NAME == abcd and DESCRIPTION == absd"
|
||||
+ " and CREATEDAT =lt= 0123 and LASTMODIFIEDAT =gt= 0123"
|
||||
+ " and CONTROLLERID == 0123 and UPDATESTATUS == PENDING"
|
||||
+ " and IPADDRESS == 0123 and LASTCONTROLLERREQUESTAT == 0123" + " and tag == beta";
|
||||
|
||||
RSQLUtility.validateRsqlFor(rsql1, TargetFields.class);
|
||||
|
||||
final String rsql2 = "ASSIGNEDDS.name == abcd and ASSIGNEDDS.version == 0123"
|
||||
+ " and INSTALLEDDS.name == abcd and INSTALLEDDS.version == 0123";
|
||||
RSQLUtility.validateRsqlFor(rsql2, TargetFields.class);
|
||||
|
||||
final String rsql3 = "ATTRIBUTE.subkey1 == test and ATTRIBUTE.subkey2 == test"
|
||||
+ " and METADATA.metakey1 == abcd and METADATA.metavalue2 == asdfg";
|
||||
RSQLUtility.validateRsqlFor(rsql3, TargetFields.class);
|
||||
|
||||
final String rsql4 = "CREATEDAT =lt= ${NOW_TS} and LASTMODIFIEDAT =ge= ${OVERDUE_TS}";
|
||||
RSQLUtility.validateRsqlFor(rsql4, TargetFields.class);
|
||||
|
||||
final String rsql5 = "wrongfield == abcd";
|
||||
assertThatExceptionOfType(RSQLParameterUnsupportedFieldException.class)
|
||||
.isThrownBy(() -> RSQLUtility.validateRsqlFor(rsql5, TargetFields.class));
|
||||
}
|
||||
|
||||
private void assertRSQLQuery(final String rsqlParam, final long expcetedTargets) {
|
||||
final Page<Target> findTargetPage = targetManagement.findByRsql(PAGE, rsqlParam);
|
||||
final long countTargetsAll = findTargetPage.getTotalElements();
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2020 devolo AG and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.jpa.rsql;
|
||||
|
||||
import org.eclipse.hawkbit.repository.TargetFields;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import io.qameta.allure.Description;
|
||||
import io.qameta.allure.Feature;
|
||||
import io.qameta.allure.Story;
|
||||
|
||||
@Feature("Component Tests - Repository")
|
||||
@Story("RSQL target field validation")
|
||||
public class RSQLTargetFieldValidationTest {
|
||||
@Test
|
||||
@Description("Testing allowed RSQL keys based on TargetFields.class")
|
||||
public void rsqlValidTargetFields() {
|
||||
final String rsql1 = "ID == '0123' and NAME == abcd and DESCRIPTION == absd"
|
||||
+ " and CREATEDAT =lt= 0123 and LASTMODIFIEDAT =gt= 0123"
|
||||
+ " and CONTROLLERID == 0123 and UPDATESTATUS == PENDING"
|
||||
+ " and IPADDRESS == 0123 and LASTCONTROLLERREQUESTAT == 0123" + " and tag == beta";
|
||||
|
||||
RSQLUtility.validateRsqlFor(rsql1, TargetFields.class);
|
||||
|
||||
final String rsql2 = "ASSIGNEDDS.name == abcd and ASSIGNEDDS.version == 0123"
|
||||
+ " and INSTALLEDDS.name == abcd and INSTALLEDDS.version == 0123";
|
||||
RSQLUtility.validateRsqlFor(rsql2, TargetFields.class);
|
||||
|
||||
final String rsql3 = "ATTRIBUTE.subkey1 == test and ATTRIBUTE.subkey2 == test"
|
||||
+ " and METADATA.metakey1 == abcd and METADATA.metavalue2 == asdfg";
|
||||
RSQLUtility.validateRsqlFor(rsql3, TargetFields.class);
|
||||
|
||||
final String rsql4 = "CREATEDAT =lt= ${NOW_TS} and LASTMODIFIEDAT =ge= ${OVERDUE_TS}";
|
||||
RSQLUtility.validateRsqlFor(rsql4, TargetFields.class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user