Improve JPA Provider portability - RSQL (#2131)
Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -63,8 +63,6 @@ public class RSQLActionFieldsTest extends AbstractJpaIntegrationTest {
|
||||
return;
|
||||
}
|
||||
|
||||
assertRSQLQuery(ActionFields.ID.name() + "==*", 11);
|
||||
assertRSQLQuery(ActionFields.ID.name() + "==noexist*", 0);
|
||||
assertRSQLQuery(ActionFields.ID.name() + "=in=(" + action.getId() + ",10000000)", 1);
|
||||
assertRSQLQuery(ActionFields.ID.name() + "=out=(" + action.getId() + ",10000000)", 10);
|
||||
}
|
||||
|
||||
@@ -81,8 +81,6 @@ public class RSQLDistributionSetFieldTest extends AbstractJpaIntegrationTest {
|
||||
return;
|
||||
}
|
||||
|
||||
assertRSQLQuery(DistributionSetFields.ID.name() + "==*", 5);
|
||||
assertRSQLQuery(DistributionSetFields.ID.name() + "==noexist*", 0);
|
||||
assertRSQLQuery(DistributionSetFields.ID.name() + "=in=(" + ds.getId() + ",10000000)", 1);
|
||||
assertRSQLQuery(DistributionSetFields.ID.name() + "=out=(" + ds.getId() + ",10000000)", 4);
|
||||
}
|
||||
@@ -104,8 +102,8 @@ public class RSQLDistributionSetFieldTest extends AbstractJpaIntegrationTest {
|
||||
assertRSQLQuery(DistributionSetFields.MODULE.name() + "." + SoftwareModuleFields.NAME.name() + "==" + sm.getName(), 1);
|
||||
assertRSQLQuery(DistributionSetFields.MODULE.name() + "." + SoftwareModuleFields.ID.name() + "==" + sm.getId(), 1);
|
||||
assertRSQLQuery(DistributionSetFields.MODULE.name() + "." + SoftwareModuleFields.NAME.name() + "==noExist", 0);
|
||||
assertRSQLQuery(DistributionSetFields.MODULE.name() + "." + SoftwareModuleFields.ID.name() + "=in=(" + sm.getId() + ", noExist)", 1);
|
||||
assertRSQLQuery(DistributionSetFields.MODULE.name() + "." + SoftwareModuleFields.ID.name() + "=out=(" + sm.getId() + ", noExist)", 4);
|
||||
assertRSQLQuery(DistributionSetFields.MODULE.name() + "." + SoftwareModuleFields.ID.name() + "=in=(" + sm.getId() + ", -1)", 1);
|
||||
assertRSQLQuery(DistributionSetFields.MODULE.name() + "." + SoftwareModuleFields.ID.name() + "=out=(" + sm.getId() + ", -1)", 4);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -128,10 +126,8 @@ public class RSQLDistributionSetFieldTest extends AbstractJpaIntegrationTest {
|
||||
public void testFilterByParameterVersion() {
|
||||
assertRSQLQuery(DistributionSetFields.VERSION.name() + "==" + TestdataFactory.DEFAULT_VERSION, 1);
|
||||
assertRSQLQuery(DistributionSetFields.VERSION.name() + "!=" + TestdataFactory.DEFAULT_VERSION, 4);
|
||||
assertRSQLQuery(
|
||||
DistributionSetFields.VERSION.name() + "=in=(" + TestdataFactory.DEFAULT_VERSION + ",1.0.0,1.0.1)", 3);
|
||||
assertRSQLQuery(DistributionSetFields.VERSION.name() + "=out=(" + TestdataFactory.DEFAULT_VERSION + ",error)",
|
||||
4);
|
||||
assertRSQLQuery(DistributionSetFields.VERSION.name() + "=in=(" + TestdataFactory.DEFAULT_VERSION + ",1.0.0,1.0.1)", 3);
|
||||
assertRSQLQuery(DistributionSetFields.VERSION.name() + "=out=(" + TestdataFactory.DEFAULT_VERSION + ",error)", 4);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -58,8 +58,6 @@ public class RSQLRolloutGroupFieldTest extends AbstractJpaIntegrationTest {
|
||||
return;
|
||||
}
|
||||
|
||||
assertRSQLQuery(RolloutGroupFields.ID.name() + "==*", 4);
|
||||
assertRSQLQuery(RolloutGroupFields.ID.name() + "==noexist*", 0);
|
||||
assertRSQLQuery(RolloutGroupFields.ID.name() + "=in=(" + rolloutGroupId + ",10000000)", 1);
|
||||
assertRSQLQuery(RolloutGroupFields.ID.name() + "=out=(" + rolloutGroupId + ",10000000)", 3);
|
||||
}
|
||||
|
||||
@@ -71,8 +71,6 @@ public class RSQLSoftwareModuleFieldTest extends AbstractJpaIntegrationTest {
|
||||
return;
|
||||
}
|
||||
|
||||
assertRSQLQuery(SoftwareModuleFields.ID.name() + "==*", 6);
|
||||
assertRSQLQuery(SoftwareModuleFields.ID.name() + "==noexist*", 0);
|
||||
assertRSQLQuery(SoftwareModuleFields.ID.name() + "=in=(" + ah.getId() + ",1000000)", 1);
|
||||
assertRSQLQuery(SoftwareModuleFields.ID.name() + "=out=(" + ah.getId() + ",1000000)", 5);
|
||||
}
|
||||
|
||||
@@ -40,8 +40,6 @@ public class RSQLSoftwareModuleTypeFieldsTest extends AbstractJpaIntegrationTest
|
||||
return;
|
||||
}
|
||||
|
||||
assertRSQLQuery(SoftwareModuleTypeFields.ID.name() + "==*", 3);
|
||||
assertRSQLQuery(SoftwareModuleTypeFields.ID.name() + "==noexist*", 0);
|
||||
assertRSQLQuery(SoftwareModuleTypeFields.ID.name() + "=in=(" + osType.getId() + ",1000000)", 1);
|
||||
assertRSQLQuery(SoftwareModuleTypeFields.ID.name() + "=out=(" + osType.getId() + ",1000000)", 2);
|
||||
}
|
||||
|
||||
@@ -104,8 +104,6 @@ class RSQLTargetFieldTest extends AbstractJpaIntegrationTest {
|
||||
@Description("Test filter target by (controller) id")
|
||||
void testFilterByParameterId() {
|
||||
assertRSQLQuery(TargetFields.ID.name() + "==targetId123", 1);
|
||||
assertRSQLQuery(TargetFields.ID.name() + "==target*", 5);
|
||||
assertRSQLQuery(TargetFields.ID.name() + "==noExist*", 0);
|
||||
assertRSQLQuery(TargetFields.ID.name() + "!=targetId123", 4);
|
||||
assertRSQLQuery(TargetFields.ID.name() + "=in=(targetId123,notexist)", 1);
|
||||
assertRSQLQuery(TargetFields.ID.name() + "=out=(targetId123,notexist)", 4);
|
||||
|
||||
@@ -65,8 +65,6 @@ public class RSQLTargetFilterQueryFieldsTest extends AbstractJpaIntegrationTest
|
||||
return;
|
||||
}
|
||||
|
||||
assertRSQLQuery(TargetFilterQueryFields.ID.name() + "==*", 3);
|
||||
assertRSQLQuery(TargetFilterQueryFields.ID.name() + "==noexist*", 0);
|
||||
assertRSQLQuery(TargetFilterQueryFields.ID.name() + "=in=(" + filter1.getId() + ",10000000)", 1);
|
||||
assertRSQLQuery(TargetFilterQueryFields.ID.name() + "=out=(" + filter1.getId() + ",10000000)", 2);
|
||||
|
||||
|
||||
@@ -270,7 +270,7 @@ public class RSQLUtilityTest {
|
||||
reset0(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock);
|
||||
final String correctRsql = "name!=abc";
|
||||
when(baseSoftwareModuleRootMock.get("name")).thenReturn(baseSoftwareModuleRootMock);
|
||||
when(baseSoftwareModuleRootMock.getJavaType()).thenReturn((Class) SoftwareModule.class);
|
||||
when(baseSoftwareModuleRootMock.getJavaType()).thenReturn((Class) String.class);
|
||||
|
||||
when(criteriaBuilderMock.isNull(any(Expression.class))).thenReturn(mock(Predicate.class));
|
||||
when(criteriaBuilderMock.notEqual(any(Expression.class), anyString()))
|
||||
@@ -285,8 +285,7 @@ public class RSQLUtilityTest {
|
||||
// verification
|
||||
verify(criteriaBuilderMock, times(1)).or(any(Predicate.class), any(Predicate.class));
|
||||
verify(criteriaBuilderMock, times(1)).isNull(eq(pathOfString(baseSoftwareModuleRootMock)));
|
||||
verify(criteriaBuilderMock, times(1)).notEqual(eq(pathOfString(baseSoftwareModuleRootMock)),
|
||||
eq("abc".toUpperCase()));
|
||||
verify(criteriaBuilderMock, times(1)).notEqual(eq(pathOfString(baseSoftwareModuleRootMock)), eq("abc".toUpperCase()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -294,7 +293,7 @@ public class RSQLUtilityTest {
|
||||
reset0(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock);
|
||||
final String correctRsql = "name!=abc*";
|
||||
when(baseSoftwareModuleRootMock.get("name")).thenReturn(baseSoftwareModuleRootMock);
|
||||
when(baseSoftwareModuleRootMock.getJavaType()).thenReturn((Class) SoftwareModule.class);
|
||||
when(baseSoftwareModuleRootMock.getJavaType()).thenReturn((Class) String.class);
|
||||
|
||||
when(criteriaBuilderMock.isNull(any(Expression.class))).thenReturn(mock(Predicate.class));
|
||||
when(criteriaBuilderMock.notLike(any(Expression.class), anyString(), eq('\\')))
|
||||
@@ -346,7 +345,7 @@ public class RSQLUtilityTest {
|
||||
reset0(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock);
|
||||
final String correctRsql = "name==a%";
|
||||
when(baseSoftwareModuleRootMock.get("name")).thenReturn(baseSoftwareModuleRootMock);
|
||||
when(baseSoftwareModuleRootMock.getJavaType()).thenReturn((Class) SoftwareModule.class);
|
||||
when(baseSoftwareModuleRootMock.getJavaType()).thenReturn((Class) String.class);
|
||||
when(criteriaBuilderMock.equal(any(Expression.class), anyString())).thenReturn(mock(Predicate.class));
|
||||
when(criteriaBuilderMock.<String> greaterThanOrEqualTo(any(Expression.class), any(String.class)))
|
||||
.thenReturn(mock(Predicate.class));
|
||||
@@ -367,7 +366,7 @@ public class RSQLUtilityTest {
|
||||
reset0(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock);
|
||||
final String correctRsql = "name==a%*";
|
||||
when(baseSoftwareModuleRootMock.get("name")).thenReturn(baseSoftwareModuleRootMock);
|
||||
when(baseSoftwareModuleRootMock.getJavaType()).thenReturn((Class) SoftwareModule.class);
|
||||
when(baseSoftwareModuleRootMock.getJavaType()).thenReturn((Class) String.class);
|
||||
when(criteriaBuilderMock.like(any(Expression.class), anyString(), eq('\\'))).thenReturn(mock(Predicate.class));
|
||||
when(criteriaBuilderMock.<String> greaterThanOrEqualTo(any(Expression.class), any(String.class)))
|
||||
.thenReturn(mock(Predicate.class));
|
||||
@@ -388,7 +387,7 @@ public class RSQLUtilityTest {
|
||||
reset0(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock);
|
||||
final String correctRsql = "name==a%*";
|
||||
when(baseSoftwareModuleRootMock.get("name")).thenReturn(baseSoftwareModuleRootMock);
|
||||
when(baseSoftwareModuleRootMock.getJavaType()).thenReturn((Class) SoftwareModule.class);
|
||||
when(baseSoftwareModuleRootMock.getJavaType()).thenReturn((Class) String.class);
|
||||
when(criteriaBuilderMock.upper(eq(pathOfString(baseSoftwareModuleRootMock))))
|
||||
.thenReturn(pathOfString(baseSoftwareModuleRootMock));
|
||||
when(criteriaBuilderMock.like(any(Expression.class), anyString(), eq('\\'))).thenReturn(mock(Predicate.class));
|
||||
|
||||
Reference in New Issue
Block a user