Skip to content

Commit 161c1f8

Browse files
authored
Bugfix/tests catch (#309)
* fixed empty catch blocks in tests * tests code analysis fixes * bugfix IfMatch graph tests * bugfix assumeTrue to skip tests
1 parent 5afecf9 commit 161c1f8

27 files changed

+7242
-7874
lines changed

src/test/java/com/arangodb/ArangoCollectionTest.java

+2,293-2,387
Large diffs are not rendered by default.

src/test/java/com/arangodb/ArangoCursorTest.java

+19-224
Original file line numberDiff line numberDiff line change
@@ -73,135 +73,50 @@ public void next() {
7373
@Test
7474
public void mapFilterCount() {
7575
final ArangoCursor<VPackSlice> cursor = db.query("FOR i IN 0..99 RETURN i", VPackSlice.class);
76-
final long count = cursor.map(new Function<VPackSlice, Long>() {
77-
@Override
78-
public Long apply(final VPackSlice t) {
79-
return t.getAsLong();
80-
}
81-
}).filter(new Predicate<Long>() {
82-
@Override
83-
public boolean test(final Long t) {
84-
return t < 50;
85-
}
86-
}).count();
76+
final long count = cursor.map(VPackSlice::getAsLong).filter(t -> t < 50).count();
8777
assertThat(count, is(50L));
8878
}
8979

9080
@Test
9181
public void mapMapFilterCount() {
9282
final ArangoCursor<VPackSlice> cursor = db.query("FOR i IN 0..99 RETURN i", VPackSlice.class);
93-
final long count = cursor.map(new Function<VPackSlice, Long>() {
94-
@Override
95-
public Long apply(final VPackSlice t) {
96-
return t.getAsLong();
97-
}
98-
}).map(new Function<Long, Long>() {
99-
@Override
100-
public Long apply(final Long t) {
101-
return t * 10;
102-
}
103-
}).filter(new Predicate<Long>() {
104-
@Override
105-
public boolean test(final Long t) {
106-
return t < 500;
107-
}
108-
}).count();
83+
final long count = cursor.map(VPackSlice::getAsLong).map(t -> t * 10).filter(t -> t < 500).count();
10984
assertThat(count, is(50L));
11085
}
11186

11287
@Test
11388
public void mapMapFilterFilterCount() {
11489
final ArangoCursor<VPackSlice> cursor = db.query("FOR i IN 0..99 RETURN i", VPackSlice.class);
115-
final long count = cursor.map(new Function<VPackSlice, Long>() {
116-
@Override
117-
public Long apply(final VPackSlice t) {
118-
return t.getAsLong();
119-
}
120-
}).map(new Function<Long, Long>() {
121-
@Override
122-
public Long apply(final Long t) {
123-
return t * 10;
124-
}
125-
}).filter(new Predicate<Long>() {
126-
@Override
127-
public boolean test(final Long t) {
128-
return t < 500;
129-
}
130-
}).filter(new Predicate<Long>() {
131-
@Override
132-
public boolean test(final Long t) {
133-
return t < 250;
134-
}
135-
}).count();
90+
final long count = cursor.map(VPackSlice::getAsLong).map(t -> t * 10).filter(t -> t < 500).filter(t -> t < 250).count();
13691
assertThat(count, is(25L));
13792
}
13893

13994
@Test
14095
public void mapFilterNext() {
14196
final ArangoCursor<VPackSlice> cursor = db.query("FOR i IN 0..99 RETURN i", VPackSlice.class);
142-
final long count = cursor.map(new Function<VPackSlice, Long>() {
143-
@Override
144-
public Long apply(final VPackSlice t) {
145-
return t.getAsLong();
146-
}
147-
}).filter(new Predicate<Long>() {
148-
@Override
149-
public boolean test(final Long t) {
150-
return t < 50;
151-
}
152-
}).iterator().next();
97+
final long count = cursor.map(VPackSlice::getAsLong).filter(t -> t < 50).iterator().next();
15398
assertThat(count, is(0L));
15499
}
155100

156101
@Test
157102
public void mapFilterFirst() {
158103
final ArangoCursor<VPackSlice> cursor = db.query("FOR i IN 0..99 RETURN i", VPackSlice.class);
159-
final long count = cursor.map(new Function<VPackSlice, Long>() {
160-
@Override
161-
public Long apply(final VPackSlice t) {
162-
return t.getAsLong();
163-
}
164-
}).filter(new Predicate<Long>() {
165-
@Override
166-
public boolean test(final Long t) {
167-
return t < 50;
168-
}
169-
}).first();
104+
final long count = cursor.map(VPackSlice::getAsLong).filter(t -> t < 50).first();
170105
assertThat(count, is(0L));
171106
}
172107

173108
@Test
174109
public void mapFilterCollectIntoList() {
175110
final ArangoCursor<VPackSlice> cursor = db.query("FOR i IN 0..99 RETURN i", VPackSlice.class);
176-
final List<Long> target = cursor.map(new Function<VPackSlice, Long>() {
177-
@Override
178-
public Long apply(final VPackSlice t) {
179-
return t.getAsLong();
180-
}
181-
}).filter(new Predicate<Long>() {
182-
@Override
183-
public boolean test(final Long t) {
184-
return t < 50;
185-
}
186-
}).collectInto(new ArrayList<Long>());
111+
final List<Long> target = cursor.map(VPackSlice::getAsLong).filter(t -> t < 50).collectInto(new ArrayList<>());
187112
assertThat(target, is(not(nullValue())));
188113
assertThat(target.size(), is(50));
189114
}
190115

191116
@Test
192117
public void mapFilterCollectIntoSet() {
193118
final ArangoCursor<VPackSlice> cursor = db.query("FOR i IN 0..99 RETURN i", VPackSlice.class);
194-
final Set<Long> target = cursor.map(new Function<VPackSlice, Long>() {
195-
@Override
196-
public Long apply(final VPackSlice t) {
197-
return t.getAsLong();
198-
}
199-
}).filter(new Predicate<Long>() {
200-
@Override
201-
public boolean test(final Long t) {
202-
return t < 50;
203-
}
204-
}).collectInto(new HashSet<Long>());
119+
final Set<Long> target = cursor.map(VPackSlice::getAsLong).filter(t -> t < 50).collectInto(new HashSet<>());
205120
assertThat(target, is(not(nullValue())));
206121
assertThat(target.size(), is(50));
207122
}
@@ -210,203 +125,83 @@ public boolean test(final Long t) {
210125
public void foreach() {
211126
final AtomicLong i = new AtomicLong(0L);
212127
final ArangoCursor<VPackSlice> cursor = db.query("FOR i IN 0..99 RETURN i", VPackSlice.class);
213-
cursor.foreach(new Consumer<VPackSlice>() {
214-
@Override
215-
public void accept(final VPackSlice t) {
216-
assertThat(t.getAsLong(), is(i.getAndIncrement()));
217-
}
218-
});
128+
cursor.foreach(t -> assertThat(t.getAsLong(), is(i.getAndIncrement())));
219129
}
220130

221131
@Test
222132
public void mapForeach() {
223133
final AtomicLong i = new AtomicLong(0L);
224134
final ArangoCursor<VPackSlice> cursor = db.query("FOR i IN 0..99 RETURN i", VPackSlice.class);
225-
cursor.map(new Function<VPackSlice, Long>() {
226-
@Override
227-
public Long apply(final VPackSlice t) {
228-
return t.getAsLong();
229-
}
230-
}).foreach(new Consumer<Long>() {
231-
@Override
232-
public void accept(final Long t) {
233-
assertThat(t, is(i.getAndIncrement()));
234-
}
235-
});
135+
cursor.map(VPackSlice::getAsLong).foreach(t -> assertThat(t, is(i.getAndIncrement())));
236136
}
237137

238138
@Test
239139
public void mapFilterForeach() {
240140
final AtomicLong i = new AtomicLong(0L);
241141
final ArangoCursor<VPackSlice> cursor = db.query("FOR i IN 0..99 RETURN i", VPackSlice.class);
242-
cursor.map(new Function<VPackSlice, Long>() {
243-
@Override
244-
public Long apply(final VPackSlice t) {
245-
return t.getAsLong();
246-
}
247-
}).filter(new Predicate<Long>() {
248-
@Override
249-
public boolean test(final Long t) {
250-
return t < 50;
251-
}
252-
}).foreach(new Consumer<Long>() {
253-
@Override
254-
public void accept(final Long t) {
255-
assertThat(t, is(i.getAndIncrement()));
256-
}
257-
});
142+
cursor.map(VPackSlice::getAsLong).filter(t -> t < 50).foreach(t -> assertThat(t, is(i.getAndIncrement())));
258143
}
259144

260145
@Test
261146
public void anyMatch() {
262147
final ArangoCursor<VPackSlice> cursor = db.query("FOR i IN 0..99 RETURN i", VPackSlice.class);
263-
final boolean match = cursor.anyMatch(new Predicate<VPackSlice>() {
264-
@Override
265-
public boolean test(final VPackSlice t) {
266-
return t.getAsLong() == 50L;
267-
}
268-
});
148+
final boolean match = cursor.anyMatch(t -> t.getAsLong() == 50L);
269149
assertThat(match, is(true));
270150
}
271151

272152
@Test
273153
public void mapAnyMatch() {
274154
final ArangoCursor<VPackSlice> cursor = db.query("FOR i IN 0..99 RETURN i", VPackSlice.class);
275-
final boolean match = cursor.map(new Function<VPackSlice, Long>() {
276-
@Override
277-
public Long apply(final VPackSlice t) {
278-
return t.getAsLong();
279-
}
280-
}).anyMatch(new Predicate<Long>() {
281-
@Override
282-
public boolean test(final Long t) {
283-
return t == 50L;
284-
}
285-
});
155+
final boolean match = cursor.map(VPackSlice::getAsLong).anyMatch(t -> t == 50L);
286156
assertThat(match, is(true));
287157
}
288158

289159
@Test
290160
public void mapFilterAnyMatch() {
291161
final ArangoCursor<VPackSlice> cursor = db.query("FOR i IN 0..99 RETURN i", VPackSlice.class);
292-
final boolean match = cursor.map(new Function<VPackSlice, Long>() {
293-
@Override
294-
public Long apply(final VPackSlice t) {
295-
return t.getAsLong();
296-
}
297-
}).filter(new Predicate<Long>() {
298-
@Override
299-
public boolean test(final Long t) {
300-
return t < 50;
301-
}
302-
}).anyMatch(new Predicate<Long>() {
303-
@Override
304-
public boolean test(final Long t) {
305-
return t == 25L;
306-
}
307-
});
162+
final boolean match = cursor.map(VPackSlice::getAsLong).filter(t -> t < 50).anyMatch(t -> t == 25L);
308163
assertThat(match, is(true));
309164
}
310165

311166
@Test
312167
public void noneMatch() {
313168
final ArangoCursor<VPackSlice> cursor = db.query("FOR i IN 0..99 RETURN i", VPackSlice.class);
314-
final boolean match = cursor.noneMatch(new Predicate<VPackSlice>() {
315-
@Override
316-
public boolean test(final VPackSlice t) {
317-
return t.getAsLong() == 100L;
318-
}
319-
});
169+
final boolean match = cursor.noneMatch(t -> t.getAsLong() == 100L);
320170
assertThat(match, is(true));
321171
}
322172

323173
@Test
324174
public void mapNoneMatch() {
325175
final ArangoCursor<VPackSlice> cursor = db.query("FOR i IN 0..99 RETURN i", VPackSlice.class);
326-
final boolean match = cursor.map(new Function<VPackSlice, Long>() {
327-
@Override
328-
public Long apply(final VPackSlice t) {
329-
return t.getAsLong();
330-
}
331-
}).noneMatch(new Predicate<Long>() {
332-
@Override
333-
public boolean test(final Long t) {
334-
return t == 100L;
335-
}
336-
});
176+
final boolean match = cursor.map(VPackSlice::getAsLong).noneMatch(t -> t == 100L);
337177
assertThat(match, is(true));
338178
}
339179

340180
@Test
341181
public void mapFilterNoneMatch() {
342182
final ArangoCursor<VPackSlice> cursor = db.query("FOR i IN 0..99 RETURN i", VPackSlice.class);
343-
final boolean match = cursor.map(new Function<VPackSlice, Long>() {
344-
@Override
345-
public Long apply(final VPackSlice t) {
346-
return t.getAsLong();
347-
}
348-
}).filter(new Predicate<Long>() {
349-
@Override
350-
public boolean test(final Long t) {
351-
return t < 50;
352-
}
353-
}).noneMatch(new Predicate<Long>() {
354-
@Override
355-
public boolean test(final Long t) {
356-
return t == 50L;
357-
}
358-
});
183+
final boolean match = cursor.map(VPackSlice::getAsLong).filter(t -> t < 50).noneMatch(t -> t == 50L);
359184
assertThat(match, is(true));
360185
}
361186

362187
@Test
363188
public void allMatch() {
364189
final ArangoCursor<VPackSlice> cursor = db.query("FOR i IN 0..99 RETURN i", VPackSlice.class);
365-
final boolean match = cursor.allMatch(new Predicate<VPackSlice>() {
366-
@Override
367-
public boolean test(final VPackSlice t) {
368-
return t.getAsLong() < 100L;
369-
}
370-
});
190+
final boolean match = cursor.allMatch(t -> t.getAsLong() < 100L);
371191
assertThat(match, is(true));
372192
}
373193

374194
@Test
375195
public void mapAllMatch() {
376196
final ArangoCursor<VPackSlice> cursor = db.query("FOR i IN 0..99 RETURN i", VPackSlice.class);
377-
final boolean match = cursor.map(new Function<VPackSlice, Long>() {
378-
@Override
379-
public Long apply(final VPackSlice t) {
380-
return t.getAsLong();
381-
}
382-
}).allMatch(new Predicate<Long>() {
383-
@Override
384-
public boolean test(final Long t) {
385-
return t < 100;
386-
}
387-
});
197+
final boolean match = cursor.map(VPackSlice::getAsLong).allMatch(t -> t < 100);
388198
assertThat(match, is(true));
389199
}
390200

391201
@Test
392202
public void mapFilterAllMatch() {
393203
final ArangoCursor<VPackSlice> cursor = db.query("FOR i IN 0..99 RETURN i", VPackSlice.class);
394-
final boolean match = cursor.map(new Function<VPackSlice, Long>() {
395-
@Override
396-
public Long apply(final VPackSlice t) {
397-
return t.getAsLong();
398-
}
399-
}).filter(new Predicate<Long>() {
400-
@Override
401-
public boolean test(final Long t) {
402-
return t < 50;
403-
}
404-
}).allMatch(new Predicate<Long>() {
405-
@Override
406-
public boolean test(final Long t) {
407-
return t < 50;
408-
}
409-
});
204+
final boolean match = cursor.map(VPackSlice::getAsLong).filter(t -> t < 50).allMatch(t -> t < 50);
410205
assertThat(match, is(true));
411206
}
412207
}

0 commit comments

Comments
 (0)