|
|
|
@ -23,10 +23,10 @@ class CriteriaTest : BaseFilterInstrumentedUnitTest() { |
|
|
|
val cal = Calendar.getInstance() |
|
|
|
val cal = Calendar.getInstance() |
|
|
|
cal.time = Date() |
|
|
|
cal.time = Date() |
|
|
|
val s1 = Session.testInstance(100.0, false, cal.time) |
|
|
|
val s1 = Session.testInstance(100.0, false, cal.time) |
|
|
|
|
|
|
|
val firstValue = cal.get(Calendar.YEAR) |
|
|
|
cal.add(Calendar.YEAR, 1) |
|
|
|
cal.add(Calendar.YEAR, 1) |
|
|
|
Session.testInstance(100.0, true, cal.time) |
|
|
|
Session.testInstance(100.0, true, cal.time) |
|
|
|
cal.add(Calendar.YEAR, -11) |
|
|
|
cal.add(Calendar.YEAR, -11) |
|
|
|
val firstValue = cal.get(Calendar.YEAR) |
|
|
|
|
|
|
|
Session.testInstance(100.0, true, cal.time) |
|
|
|
Session.testInstance(100.0, true, cal.time) |
|
|
|
cal.add(Calendar.YEAR, 7) |
|
|
|
cal.add(Calendar.YEAR, 7) |
|
|
|
Session.testInstance(100.0, true, cal.time) |
|
|
|
Session.testInstance(100.0, true, cal.time) |
|
|
|
@ -35,23 +35,23 @@ class CriteriaTest : BaseFilterInstrumentedUnitTest() { |
|
|
|
cal.add(Calendar.YEAR, 10) |
|
|
|
cal.add(Calendar.YEAR, 10) |
|
|
|
Session.testInstance(100.0, true, cal.time) |
|
|
|
Session.testInstance(100.0, true, cal.time) |
|
|
|
|
|
|
|
|
|
|
|
val lastValue = firstValue + 10 |
|
|
|
val lastValue = firstValue + 5 |
|
|
|
|
|
|
|
|
|
|
|
realm.commitTransaction() |
|
|
|
realm.commitTransaction() |
|
|
|
|
|
|
|
|
|
|
|
val years = Criteria.Years.queryConditions as List<QueryCondition.AnyYear> |
|
|
|
val years = Criteria.Years.queryConditions as List<QueryCondition.AnyYear> |
|
|
|
println("years = ${years.map { it.getDisplayName() }}") |
|
|
|
println("years = ${years.map { it.getDisplayName() }}") |
|
|
|
|
|
|
|
|
|
|
|
assertEquals(11, years.size) |
|
|
|
assertEquals(16, years.size) |
|
|
|
assertEquals(firstValue, years.first().listOfValues.first()) |
|
|
|
assertEquals(firstValue-10, years.first().listOfValues.first()) |
|
|
|
assertEquals(lastValue, years.last().listOfValues.first()) |
|
|
|
assertEquals(lastValue, years.last().listOfValues.first()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
fun combined() { |
|
|
|
fun combined() { |
|
|
|
|
|
|
|
|
|
|
|
val critierias = listOf(Criteria.MonthsOfYear, Criteria.DaysOfWeek) |
|
|
|
val criterias = listOf(Criteria.MonthsOfYear, Criteria.DaysOfWeek) |
|
|
|
val combined = critierias.combined() |
|
|
|
val combined = criterias.combined() |
|
|
|
combined.forEach { |
|
|
|
combined.forEach { |
|
|
|
it.forEach {qc-> |
|
|
|
it.forEach {qc-> |
|
|
|
println(qc.getDisplayName()) |
|
|
|
println(qc.getDisplayName()) |
|
|
|
@ -82,23 +82,12 @@ class CriteriaTest : BaseFilterInstrumentedUnitTest() { |
|
|
|
|
|
|
|
|
|
|
|
realm.commitTransaction() |
|
|
|
realm.commitTransaction() |
|
|
|
|
|
|
|
|
|
|
|
val critierias = listOf(Criteria.Years, Criteria.MonthsOfYear) |
|
|
|
val allMonths = Criteria.AllMonthsUpToNow.predicates |
|
|
|
val combined = critierias.combined() |
|
|
|
allMonths.forEach { |
|
|
|
combined.forEach { |
|
|
|
|
|
|
|
it.forEach {qc-> |
|
|
|
it.forEach {qc-> |
|
|
|
println("<<<<< ${qc.getDisplayName()}") |
|
|
|
println("<<<<< ${qc.getDisplayName()}") |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
println("<<<<< reduced") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val reduced= critierias.combined().upToNow() |
|
|
|
|
|
|
|
reduced.forEach { |
|
|
|
|
|
|
|
it.forEach {qc-> |
|
|
|
|
|
|
|
println("<<<<< ${qc.getDisplayName()}") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |