@Override public Long apply(Integer n) { return Long.valueOf(n); } };
@Override @CachePut(cacheNames = "testCache", condition = "#arg.equals(3)") public Long conditionalUpdate(Object arg) { return Long.valueOf(arg.toString()); }
public void testCompare() { for (long x : VALUES) { for (long y : VALUES) { // note: spec requires only that the sign is the same assertEquals(x + ", " + y, Long.valueOf(x).compareTo(y), Longs.compare(x, y)); } } }
void check() { runTester(); FromTo<?, ?> defaultFunction = (FromTo<?, ?>) getDefaultParameterValue(0); assertEquals(0, defaultFunction.apply(null)); Supplier<?> defaultSupplier = (Supplier<?>) defaultFunction; assertEquals(Long.valueOf(0), defaultSupplier.get()); } }
@Override @Caching(put = { @CachePut("primary"), @CachePut("secondary") }) public Long multiUpdate(Object arg1) { return Long.valueOf(arg1.toString()); }
@Override @Caching(put = { @CachePut("primary"), @CachePut("secondary") }) public Long multiUpdate(Object arg1) { return Long.valueOf(arg1.toString()); }
@Test public void convertCollectionToObject() { List<Long> list = Collections.singletonList(3L); Long result = conversionService.convert(list, Long.class); assertEquals(Long.valueOf(3), result); }
@Test public void nullSafeToStringWithObjectArray() { Object[] array = {"Han", Long.valueOf(43)}; assertEquals("{Han, 43}", ObjectUtils.nullSafeToString(array)); }
@Test public void withLong() { Collection<Long> col = new HashSet<>(1); col.add(5L); assertEquals(Long.valueOf(5L), DataAccessUtils.uniqueResult(col)); assertEquals(Long.valueOf(5L), DataAccessUtils.requiredUniqueResult(col)); assertEquals(Long.valueOf(5L), DataAccessUtils.objectResult(col, Long.class)); assertEquals("5", DataAccessUtils.objectResult(col, String.class)); assertEquals(5, DataAccessUtils.intResult(col)); assertEquals(5, DataAccessUtils.longResult(col)); }
@Test(timeout = 1000, expected = NoSuchElementException.class) public void testSimpleJustNext() { TestScheduler scheduler = new TestScheduler(); Flowable<Long> source = Flowable.interval(1, TimeUnit.SECONDS, scheduler).take(10); Iterable<Long> iter = source.blockingLatest(); Iterator<Long> it = iter.iterator(); // only 9 because take(10) will immediately call onComplete when receiving the 10th item // which onComplete will overwrite the previous value for (int i = 0; i < 10; i++) { scheduler.advanceTimeBy(1, TimeUnit.SECONDS); Assert.assertEquals(Long.valueOf(i), it.next()); } }
@Test(timeout = 1000, expected = NoSuchElementException.class) public void testSimpleJustNext() { TestScheduler scheduler = new TestScheduler(); Observable<Long> source = Observable.interval(1, TimeUnit.SECONDS, scheduler).take(10); Iterable<Long> iter = source.blockingLatest(); Iterator<Long> it = iter.iterator(); // only 9 because take(10) will immediately call onComplete when receiving the 10th item // which onComplete will overwrite the previous value for (int i = 0; i < 10; i++) { scheduler.advanceTimeBy(1, TimeUnit.SECONDS); Assert.assertEquals(Long.valueOf(i), it.next()); } }
@Test public void convertObjectToObjectFinderMethodWithIdConversion() { TestEntity entity = conversionService.convert("1", TestEntity.class); assertEquals(Long.valueOf(1), entity.getId()); }
@Test public void convertObjectToObjectFinderMethod() { TestEntity e = conversionService.convert(1L, TestEntity.class); assertEquals(Long.valueOf(1), e.getId()); }
@Test public void setFieldWithNullNameAndNullType() throws Exception { exception.expect(IllegalArgumentException.class); exception.expectMessage(startsWith("Either name or type")); setField(person, null, Long.valueOf(99), null); }
@Test public void setFieldWithNullTargetObject() throws Exception { exception.expect(IllegalArgumentException.class); exception.expectMessage(startsWith("Either targetObject or targetClass")); setField((Object) null, "id", Long.valueOf(99)); }
@Test public void setFieldWithWrongType() throws Exception { exception.expect(IllegalArgumentException.class); exception.expectMessage(startsWith("Could not find field")); setField(person, "id", Long.valueOf(99), String.class); }
@Test public void setFieldWithBogusName() throws Exception { exception.expect(IllegalArgumentException.class); exception.expectMessage(startsWith("Could not find field 'bogus'")); setField(person, "bogus", Long.valueOf(99), long.class); }
@Test public void contentLength() { Mono<ServerResponse> result = ServerResponse.ok().contentLength(42).build(); StepVerifier.create(result) .expectNextMatches(response -> Long.valueOf(42).equals(response.headers().getContentLength())) .expectComplete() .verify(); }