Skip to content

Commit 5220977

Browse files
dbulahovstbischof
authored andcommitted
add rewrite-maven-plugin
Signed-off-by: dbulahov <bulahovdenis@gmail.com>
1 parent b3d2ae1 commit 5220977

File tree

20 files changed

+407
-472
lines changed

20 files changed

+407
-472
lines changed

common/src/test/java/org/eclipse/daanse/olap/calc/base/type/tuplebase/ArrayTupleListTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
*/
1414
package org.eclipse.daanse.olap.calc.base.type.tuplebase;
1515

16+
import static org.assertj.core.api.Assertions.assertThat;
1617
import static org.assertj.core.api.Assertions.assertThatThrownBy;
1718
import static org.assertj.core.api.ListAssert.assertThatList;
18-
import static org.junit.jupiter.api.Assertions.assertEquals;
1919

2020
import org.eclipse.daanse.olap.api.element.Member;
2121
import org.eclipse.daanse.olap.common.ResourceLimitExceededException;
@@ -29,7 +29,7 @@
2929
class ArrayTupleListTest {
3030

3131
@AfterEach
32-
public void afterEach() {
32+
void afterEach() {
3333
SystemWideProperties.instance().populateInitial();
3434
}
3535

@@ -48,8 +48,8 @@ void addOverInitialCapacity() {
4848
atlList = new ArrayTupleList(2, 10);
4949
addTuplesToList(atlList, count);
5050

51-
assertThatList(atlList).hasSize(count).anySatisfy(tuple -> assertEquals(tuple.get(0), m1))
52-
.anySatisfy(tuple -> assertEquals(tuple.get(1), m2));
51+
assertThatList(atlList).hasSize(count).anySatisfy(tuple -> assertThat(m1).isEqualTo(tuple.get(0)))
52+
.anySatisfy(tuple -> assertThat(m2).isEqualTo(tuple.get(1)));
5353
}
5454

5555
@Test

common/src/test/java/org/eclipse/daanse/olap/fun/sort/PartialSortTest.java

Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@
2929

3030
package org.eclipse.daanse.olap.fun.sort;
3131

32-
import static org.junit.jupiter.api.Assertions.assertFalse;
33-
import static org.junit.jupiter.api.Assertions.assertTrue;
32+
import static org.assertj.core.api.Assertions.assertThat;
3433

3534
import java.util.Arrays;
3635
import java.util.Comparator;
@@ -164,7 +163,7 @@ private static <T> boolean isPartiallySorted(T[] vec, int limit, Comparator<? su
164163

165164
// validate the predicate isPartiallySorted()
166165
@Test
167-
void testPredicate1() {
166+
void predicate1() {
168167
int errct = 0;
169168
int size = 10 * 1000;
170169
int[] vec = new int[size];
@@ -229,12 +228,12 @@ void testPredicate1() {
229228
errct++;
230229
}
231230

232-
assertTrue(errct == 0);
231+
assertThat(errct).isEqualTo(0);
233232
}
234233

235234
// same as testPredicate() but boxed
236235
@Test
237-
void testPredicate2() {
236+
void predicate2() {
238237
int errct = 0;
239238
int size = 10 * 1000;
240239
Integer[] vec = new Integer[size];
@@ -300,21 +299,21 @@ void testPredicate2() {
300299
errct++;
301300
}
302301

303-
assertTrue(errct == 0);
302+
assertThat(errct).isEqualTo(0);
304303
}
305304

306305
@Test
307-
void testQuick() {
306+
void quick() {
308307
final int length = 40;
309308
final int limit = 4;
310309
Integer[] vec = newRandomIntegers(length, 0, length);
311310
// sort descending
312311
doPartialSort(vec, true, limit);
313-
assertTrue(isPartiallySorted(vec, limit, true));
312+
assertThat(isPartiallySorted(vec, limit, true)).isTrue();
314313
}
315314

316315
@Test
317-
void testOnAlreadySorted() {
316+
void onAlreadySorted() {
318317
final int length = 200;
319318
final int limit = 8;
320319
Integer[] vec = new Integer[length];
@@ -323,11 +322,11 @@ void testOnAlreadySorted() {
323322
}
324323
// sort ascending
325324
doPartialSort(vec, false, limit);
326-
assertTrue(isPartiallySorted(vec, limit, false));
325+
assertThat(isPartiallySorted(vec, limit, false)).isTrue();
327326
}
328327

329328
@Test
330-
void testOnAlreadyReverseSorted() {
329+
void onAlreadyReverseSorted() {
331330
final int length = 200;
332331
final int limit = 8;
333332
Integer[] vec = new Integer[length];
@@ -336,43 +335,43 @@ void testOnAlreadyReverseSorted() {
336335
}
337336
// sort ascending
338337
doPartialSort(vec, false, limit);
339-
assertTrue(isPartiallySorted(vec, limit, false));
338+
assertThat(isPartiallySorted(vec, limit, false)).isTrue();
340339
}
341340

342341
// tests partial sort on arras of random integers
343342
private void randomIntegerTests(int length, int limit) {
344343
Integer[] vec = newRandomIntegers(length, 0, length);
345344
// sort descending
346345
doPartialSort(vec, true, limit);
347-
assertTrue(isPartiallySorted(vec, limit, true));
346+
assertThat(isPartiallySorted(vec, limit, true)).isTrue();
348347

349348
// sort ascending
350349
vec = newRandomIntegers(length, 0, length);
351350
doPartialSort(vec, false, limit);
352-
assertTrue(isPartiallySorted(vec, limit, false));
351+
assertThat(isPartiallySorted(vec, limit, false)).isTrue();
353352

354353
// both again with a wider range of values
355354
vec = newRandomIntegers(length, 10, 4 * length);
356355
doPartialSort(vec, true, limit);
357-
assertTrue(isPartiallySorted(vec, limit, true));
356+
assertThat(isPartiallySorted(vec, limit, true)).isTrue();
358357

359358
vec = newRandomIntegers(length, 10, 4 * length);
360359
doPartialSort(vec, false, limit);
361-
assertTrue(isPartiallySorted(vec, limit, false));
360+
assertThat(isPartiallySorted(vec, limit, false)).isTrue();
362361

363362
// and again with a narrower range values
364363
vec = newRandomIntegers(length, 0, length / 10);
365364
doPartialSort(vec, true, limit);
366-
assertTrue(isPartiallySorted(vec, limit, true));
365+
assertThat(isPartiallySorted(vec, limit, true)).isTrue();
367366

368367
vec = newRandomIntegers(length, 0, length / 10);
369368
doPartialSort(vec, false, limit);
370-
assertTrue(isPartiallySorted(vec, limit, false));
369+
assertThat(isPartiallySorted(vec, limit, false)).isTrue();
371370
}
372371

373372
// test correctness
374373
@Test
375-
void testOnRandomIntegers() {
374+
void onRandomIntegers() {
376375
randomIntegerTests(100, 20);
377376
randomIntegerTests(50000, 10);
378377
randomIntegerTests(50000, 500);
@@ -381,7 +380,7 @@ void testOnRandomIntegers() {
381380

382381
// test with large vector
383382
@Test
384-
void testOnManyRandomIntegers() {
383+
void onManyRandomIntegers() {
385384
randomIntegerTests(1000 * 1000, 5000);
386385
randomIntegerTests(1000 * 1000, 10);
387386
}
@@ -445,64 +444,64 @@ private Item[] doStablePartialSort(Item[] vec, boolean desc, int limit) {
445444
}
446445

447446
@Test
448-
void testPredicateIsStablySorted() {
447+
void predicateIsStablySorted() {
449448
Item[] vec = newPartlySortedItems(24, 4, false);
450-
assertTrue(Item.isStablySorted(vec, 4, false));
451-
assertFalse(Item.isStablySorted(vec, 4, true));
449+
assertThat(Item.isStablySorted(vec, 4, false)).isTrue();
450+
assertThat(Item.isStablySorted(vec, 4, true)).isFalse();
452451

453452
vec = newPartlySortedItems(24, 8, true);
454-
assertTrue(Item.isStablySorted(vec, 4, true));
455-
assertFalse(Item.isStablySorted(vec, 4, false));
453+
assertThat(Item.isStablySorted(vec, 4, true)).isTrue();
454+
assertThat(Item.isStablySorted(vec, 4, false)).isFalse();
456455

457456
vec = newPartlySortedItems(1000, 100, true);
458-
assertTrue(Item.isStablySorted(vec, 100, true));
459-
assertTrue(Item.isStablySorted(vec, 20, true));
460-
assertTrue(Item.isStablySorted(vec, 4, true));
457+
assertThat(Item.isStablySorted(vec, 100, true)).isTrue();
458+
assertThat(Item.isStablySorted(vec, 20, true)).isTrue();
459+
assertThat(Item.isStablySorted(vec, 4, true)).isTrue();
461460
}
462461

463462
@Test
464-
void testStableQuick() {
463+
void stableQuick() {
465464
final int length = 40;
466465
final int limit = 4;
467466
Item[] vec = newRandomItems(length, 0, length);
468467
// sort descending
469468
vec = doStablePartialSort(vec, true, limit);
470-
assertTrue(Item.isStablySorted(vec, limit, true));
469+
assertThat(Item.isStablySorted(vec, limit, true)).isTrue();
471470
}
472471

473472
// tests stable partial sort on arras of random Items
474473
private void randomItemTests(int length, int limit) {
475474
Item[] vec = newRandomItems(length, 0, length);
476475
// sort descending
477476
vec = doStablePartialSort(vec, true, limit);
478-
assertTrue(Item.isStablySorted(vec, limit, true));
477+
assertThat(Item.isStablySorted(vec, limit, true)).isTrue();
479478

480479
// sort ascending
481480
vec = newRandomItems(length, 0, length);
482481
vec = doStablePartialSort(vec, false, limit);
483-
assertTrue(Item.isStablySorted(vec, limit, false));
482+
assertThat(Item.isStablySorted(vec, limit, false)).isTrue();
484483

485484
// both again with a wider range of values
486485
vec = newRandomItems(length, 10, 4 * length);
487486
vec = doStablePartialSort(vec, true, limit);
488-
assertTrue(Item.isStablySorted(vec, limit, true));
487+
assertThat(Item.isStablySorted(vec, limit, true)).isTrue();
489488

490489
vec = newRandomItems(length, 10, 4 * length);
491490
vec = doStablePartialSort(vec, false, limit);
492-
assertTrue(Item.isStablySorted(vec, limit, false));
491+
assertThat(Item.isStablySorted(vec, limit, false)).isTrue();
493492

494493
// and again with a narrower range values
495494
vec = newRandomItems(length, 0, length / 10);
496495
vec = doStablePartialSort(vec, true, limit);
497-
assertTrue(Item.isStablySorted(vec, limit, true));
496+
assertThat(Item.isStablySorted(vec, limit, true)).isTrue();
498497

499498
vec = newRandomItems(length, 0, length / 10);
500499
vec = doStablePartialSort(vec, false, limit);
501-
assertTrue(Item.isStablySorted(vec, limit, false));
500+
assertThat(Item.isStablySorted(vec, limit, false)).isTrue();
502501
}
503502

504503
@Test
505-
void testStableOnRandomItems() {
504+
void stableOnRandomItems() {
506505
randomItemTests(100, 20);
507506
randomItemTests(50000, 10);
508507
randomItemTests(50000, 500);
@@ -553,7 +552,7 @@ private void speedTest(Logger logger, int length, int limit) {
553552

554553
// compare speed on different sizes of input
555554
@Test
556-
void testSpeed() {
555+
void speed() {
557556
if (!LOGGER.isDebugEnabled()) {
558557
return;
559558
}

common/src/test/java/org/eclipse/daanse/olap/fun/sort/SorterTest.java

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import static java.util.Arrays.asList;
3232
import static java.util.stream.IntStream.range;
3333
import static org.assertj.core.api.Assertions.assertThat;
34-
import static org.junit.jupiter.api.Assertions.assertTrue;
3534
import static org.mockito.Mockito.atLeastOnce;
3635
import static org.mockito.Mockito.mock;
3736
import static org.mockito.Mockito.times;
@@ -56,6 +55,7 @@
5655
import org.eclipse.daanse.olap.function.def.member.memberorderkey.MemberOrderKeyCalc;
5756
import org.eclipse.daanse.olap.query.component.QueryImpl;
5857
import org.eclipse.daanse.olap.server.ExecutionImpl;
58+
import org.junit.jupiter.api.AfterEach;
5959
import org.junit.jupiter.api.BeforeEach;
6060
import org.junit.jupiter.api.Test;
6161
import org.mockito.ArgumentCaptor;
@@ -65,6 +65,8 @@
6565

6666
class SorterTest {
6767

68+
private AutoCloseable mocks;
69+
6870
@Mock
6971
Evaluator evaluator;
7072
@Mock
@@ -103,9 +105,9 @@ class SorterTest {
103105
ArgumentCaptor<Comparator<?>> comparatorCaptor;
104106

105107
@BeforeEach
106-
public void setUp() throws Exception {
108+
void setUp() throws Exception {
107109

108-
MockitoAnnotations.initMocks(this);
110+
mocks = MockitoAnnotations.openMocks(this);
109111
when(sortKeySpec1.getKey()).thenReturn(calc1);
110112
when(sortKeySpec2.getKey()).thenReturn(calc2);
111113
when(evaluator.getQuery()).thenReturn(query);
@@ -129,7 +131,7 @@ public void setUp() throws Exception {
129131
// |Not-OrderByKey| BreakTupleComparator|HierarchicalTupleComparator |
130132
// +--------------+---------------------+------------------------------+
131133
@Test
132-
void testComparatorSelectionBrkOrderByKey() {
134+
void comparatorSelectionBrkOrderByKey() {
133135
setupSortKeyMocks(true, Sorter.SorterFlag.BASC, Sorter.SorterFlag.BDESC);
134136
Sorter.applySortSpecToComparator(evaluator, 2, comparatorChain, sortKeySpec1);
135137
Sorter.applySortSpecToComparator(evaluator, 2, comparatorChain, sortKeySpec2);
@@ -144,7 +146,7 @@ void testComparatorSelectionBrkOrderByKey() {
144146
}
145147

146148
@Test
147-
void testComparatorSelectionBrkNotOrderByKey() {
149+
void comparatorSelectionBrkNotOrderByKey() {
148150
setupSortKeyMocks(false, Sorter.SorterFlag.BASC, Sorter.SorterFlag.BDESC);
149151
Sorter.applySortSpecToComparator(evaluator, 2, comparatorChain, sortKeySpec1);
150152
Sorter.applySortSpecToComparator(evaluator, 2, comparatorChain, sortKeySpec2);
@@ -160,7 +162,7 @@ void testComparatorSelectionBrkNotOrderByKey() {
160162
}
161163

162164
@Test
163-
void testComparatorSelectionNotBreakingOrderByKey() {
165+
void comparatorSelectionNotBreakingOrderByKey() {
164166
calc1 = mock(MemberOrderKeyCalc.class);
165167
calc2 = mock(MemberOrderKeyCalc.class);
166168
when(sortKeySpec1.getKey()).thenReturn(calc1);
@@ -180,19 +182,19 @@ void testComparatorSelectionNotBreakingOrderByKey() {
180182
}
181183

182184
@Test
183-
void testComparatorSelectionNotBreaking() {
185+
void comparatorSelectionNotBreaking() {
184186
setupSortKeyMocks(false, Sorter.SorterFlag.ASC, Sorter.SorterFlag.DESC);
185187
Sorter.applySortSpecToComparator(evaluator, 2, comparatorChain, sortKeySpec1);
186188
Sorter.applySortSpecToComparator(evaluator, 2, comparatorChain, sortKeySpec2);
187189
verify(comparatorChain, times(2)).thenComparing(comparatorCaptor.capture());
188190

189191
// verify( comparatorChain, times( 2 ) ).addComparator( comparatorCaptor.capture(), eq( false ) );
190-
assertTrue(comparatorCaptor.getAllValues().get(0) instanceof HierarchicalTupleComparator);
191-
assertTrue(comparatorCaptor.getAllValues().get(1) instanceof HierarchicalTupleComparator);
192+
assertThat(comparatorCaptor.getAllValues().get(0)).isInstanceOf(HierarchicalTupleComparator.class);
193+
assertThat(comparatorCaptor.getAllValues().get(1)).isInstanceOf(HierarchicalTupleComparator.class);
192194
}
193195

194196
@Test
195-
void testSortTuplesBreakingByKey() {
197+
void sortTuplesBreakingByKey() {
196198
TupleList tupleList = genList();
197199
setupSortKeyMocks(true, Sorter.SorterFlag.BASC, Sorter.SorterFlag.BDESC);
198200

@@ -203,11 +205,11 @@ void testSortTuplesBreakingByKey() {
203205
verify(calc1, atLeastOnce()).dependsOn(hierarchy2);
204206
verify(calc2, atLeastOnce()).dependsOn(hierarchy2);
205207
verify(calc2, atLeastOnce()).dependsOn(hierarchy1);
206-
assertTrue(result.size() == 1000);
208+
assertThat(result.size()).isEqualTo(1000);
207209
}
208210

209211
@Test
210-
void testCancel() {
212+
void cancel() {
211213
setupSortKeyMocks(true, Sorter.SorterFlag.ASC, Sorter.SorterFlag.DESC);
212214
// pass in a null tupleList, and an iterable. cancel should be checked while
213215
// generating the list
@@ -244,4 +246,9 @@ private TupleList genList() {
244246
return tupleList;
245247
}
246248

249+
@AfterEach
250+
void tearDown() throws Exception {
251+
mocks.close();
252+
}
253+
247254
}

0 commit comments

Comments
 (0)