@Test public void regexMatchersWhenPatternParamThenReturnRegexRequestMatcherType() { List<RequestMatcher> requestMatchers = this.matcherRegistry.regexMatchers("/a.*"); assertThat(requestMatchers).isNotEmpty(); assertThat(requestMatchers.size()).isEqualTo(1); assertThat(requestMatchers.get(0)).isExactlyInstanceOf(RegexRequestMatcher.class); }
@Test public void antMatchersWhenPatternParamThenReturnAntPathRequestMatcherType() { List<RequestMatcher> requestMatchers = this.matcherRegistry.antMatchers("/a.*"); assertThat(requestMatchers).isNotEmpty(); assertThat(requestMatchers.size()).isEqualTo(1); assertThat(requestMatchers.get(0)).isExactlyInstanceOf(AntPathRequestMatcher.class); }
@Test public void regexMatchersWhenHttpMethodAndPatternParamsThenReturnRegexRequestMatcherType() { List<RequestMatcher> requestMatchers = this.matcherRegistry.regexMatchers(HttpMethod.GET, "/a.*"); assertThat(requestMatchers).isNotEmpty(); assertThat(requestMatchers.size()).isEqualTo(1); assertThat(requestMatchers.get(0)).isExactlyInstanceOf(RegexRequestMatcher.class); }
@Test public void antMatchersWhenHttpMethodAndPatternParamsThenReturnAntPathRequestMatcherType() { List<RequestMatcher> requestMatchers = this.matcherRegistry.antMatchers(HttpMethod.GET, "/a.*"); assertThat(requestMatchers).isNotEmpty(); assertThat(requestMatchers.size()).isEqualTo(1); assertThat(requestMatchers.get(0)).isExactlyInstanceOf(AntPathRequestMatcher.class); }
@Test public void getTemporalComparatorShouldAlwaysReturnAnInstanceOfTemporalComparator() { Comparator comparator = TypeUtils.getTemporalComparator(); assertThat(comparator).isNotNull(); assertThat(comparator).isExactlyInstanceOf(TemporalComparator.class); }
@Test public void getExtendedNumericComparatorShouldAlwaysReturnAnInstanceOfExtendedNumericComparator() { Comparator comparator = TypeUtils.getExtendedNumericComparator(); assertThat(comparator).isNotNull(); assertThat(comparator).isExactlyInstanceOf(ExtendedNumericComparator.class); }
@Test public void getNumericComparatorShouldAlwaysReturnAnInstanceOfNumericComparator() { Comparator comparator = TypeUtils.getNumericComparator(); assertThat(comparator).isNotNull(); assertThat(comparator).isExactlyInstanceOf(NumericComparator.class); }
@Test public void deserializeBlobOfMapReturnsCopyOfMap() throws Exception { final Object object = deserializeBlob(this.bytesOfMap); assertThat(object).isNotNull(); assertThat(object).isExactlyInstanceOf(HashMap.class); assertThat(object).isNotSameAs(this.mapWithTwoEntries); assertThat(object).isEqualTo(this.mapWithTwoEntries); }
public ObjectTypeAssert isMapOf(Class keyType, Class valueType) { isNotNull(); isExactlyInstanceOf(MapTypeImpl.class); org.assertj.core.api.Assertions.assertThat(((MapTypeImpl) actual).getKeyType()) .isExactlyInstanceOf(keyType); org.assertj.core.api.Assertions.assertThat(((MapTypeImpl) actual).getElementType()) .isExactlyInstanceOf(valueType); return this; } }
public ObjectTypeAssert isCollectionOf(Class componentType) { isNotNull(); isExactlyInstanceOf(CollectionTypeImpl.class); org.assertj.core.api.Assertions.assertThat(((CollectionTypeImpl) actual).getElementType()) .isExactlyInstanceOf(componentType); return this; }
@Test public void fn3Delegate() { Integer[] source = new Integer[] { 1, 2, 3, 4, 5, 6, 7, 8 }; Function<Tuple3<Integer, Integer, Integer>, Tuple3> invert = t3 -> new Tuple3<>(t3.getT3(), t3.getT2(), t3.getT1()); Tuple3 tuple = Tuples.fn3(invert).apply(source); assertThat(tuple.getT1()).isEqualTo(3); assertThat(tuple.getT2()).isEqualTo(2); assertThat(tuple.getT3()).isEqualTo(1); assertThat((Object) tuple).isExactlyInstanceOf(Tuple3.class); }
@Test public void fn4Delegate() { Integer[] source = new Integer[] { 1, 2, 3, 4, 5, 6, 7, 8 }; Function<Tuple4<Integer, Integer, Integer, Integer>, Tuple4> invert = t4 -> new Tuple4<>(t4.getT4(), t4.getT3(), t4.getT2(), t4.getT1()); Tuple4 tuple = Tuples.fn4(invert).apply(source); assertThat(tuple.getT1()).isEqualTo(4); assertThat(tuple.getT2()).isEqualTo(3); assertThat(tuple.getT3()).isEqualTo(2); assertThat(tuple.getT4()).isEqualTo(1); assertThat((Object) tuple).isExactlyInstanceOf(Tuple4.class); }
@Test public void fn5Delegate() { Integer[] source = new Integer[] { 1, 2, 3, 4, 5, 6, 7, 8 }; Function<Tuple5<Integer, Integer, Integer, Integer, Integer>, Tuple5> invert = t5 -> new Tuple5<>(t5.getT5(), t5.getT4(), t5.getT3(), t5.getT2(), t5.getT1()); Tuple5 tuple = Tuples.fn5(invert).apply(source); assertThat(tuple.getT1()).isEqualTo(5); assertThat(tuple.getT2()).isEqualTo(4); assertThat(tuple.getT3()).isEqualTo(3); assertThat(tuple.getT4()).isEqualTo(2); assertThat(tuple.getT5()).isEqualTo(1); assertThat((Object) tuple).isExactlyInstanceOf(Tuple5.class); }
@Test public void liftMonoFuseable() { Mono<Integer> source = Mono.just(1); Operators.LiftFunction<Integer, Integer> liftFunction = Operators.LiftFunction.liftScannable(null, (s, actual) -> actual); Publisher<Integer> liftOperator = liftFunction.apply(source); assertThat(liftOperator) .isInstanceOf(Mono.class) .isInstanceOf(Fuseable.class) .isExactlyInstanceOf(MonoLiftFuseable.class); assertThatCode(() -> liftOperator.subscribe(new BaseSubscriber<Integer>() {})) .doesNotThrowAnyException(); }
@Test public void liftMono() { Mono<Integer> source = Mono.just(1) .hide(); Operators.LiftFunction<Integer, Integer> liftFunction = Operators.LiftFunction.liftScannable(null, (s, actual) -> actual); Publisher<Integer> liftOperator = liftFunction.apply(source); assertThat(liftOperator) .isInstanceOf(Mono.class) .isExactlyInstanceOf(MonoLift.class); assertThatCode(() -> liftOperator.subscribe(new BaseSubscriber<Integer>() {})) .doesNotThrowAnyException(); }
@Ignore("GroupedFlux is always fuseable for now") @Test public void liftGroupedFlux() { Flux<GroupedFlux<String, Integer>> sourceGroups = Flux .just(1) .groupBy(i -> "" + i); Operators.LiftFunction<Integer, Integer> liftFunction = Operators.LiftFunction.liftScannable(null, (s, actual) -> actual); sourceGroups.map(g -> liftFunction.apply(g)) //TODO hide if GroupedFlux gets a proper hide() function .doOnNext(liftOperator -> assertThat(liftOperator) .isInstanceOf(GroupedFlux.class) .isExactlyInstanceOf(GroupedLift.class)) .blockLast(); }
@Test public void liftFlux() { Flux<Integer> source = Flux.just(1) .hide(); Operators.LiftFunction<Integer, Integer> liftFunction = Operators.LiftFunction.liftScannable(null, (s, actual) -> actual); Publisher<Integer> liftOperator = liftFunction.apply(source); assertThat(liftOperator) .isInstanceOf(Flux.class) .isExactlyInstanceOf(FluxLift.class); assertThatCode(() -> liftOperator.subscribe(new BaseSubscriber<Integer>() {})) .doesNotThrowAnyException(); }
@Test public void liftConnectableFlux() { ConnectableFlux<Integer> source = Flux.just(1) .publish(); //TODO hide if ConnectableFlux gets a hide function Operators.LiftFunction<Integer, Integer> liftFunction = Operators.LiftFunction.liftScannable(null, (s, actual) -> actual); Publisher<Integer> liftOperator = liftFunction.apply(source); assertThat(liftOperator) .isInstanceOf(ConnectableFlux.class) .isExactlyInstanceOf(ConnectableLift.class); assertThatCode(() -> liftOperator.subscribe(new BaseSubscriber<Integer>() {})) .doesNotThrowAnyException(); }
@Test public void liftFluxFuseable() { Flux<Integer> source = Flux.just(1); Operators.LiftFunction<Integer, Integer> liftFunction = Operators.LiftFunction.liftScannable(null, (s, actual) -> actual); Publisher<Integer> liftOperator = liftFunction.apply(source); assertThat(liftOperator) .isInstanceOf(Flux.class) .isInstanceOf(Fuseable.class) .isExactlyInstanceOf(FluxLiftFuseable.class); assertThatCode(() -> liftOperator.subscribe(new BaseSubscriber<Integer>() {})) .doesNotThrowAnyException(); }
@Test public void liftParallelFluxFuseable() { ParallelFlux<List<Integer>> source = Flux .just(1) .parallel(2) .collect(ArrayList::new, List::add); Operators.LiftFunction<List<Integer>, List<Integer>> liftFunction = Operators.LiftFunction.liftScannable(null, (s, actual) -> actual); Publisher<List<Integer>> liftOperator = liftFunction.apply(source); assertThat(liftOperator) .isInstanceOf(ParallelFlux.class) .isExactlyInstanceOf(ParallelLiftFuseable.class); assertThatCode(() -> liftOperator.subscribe(new BaseSubscriber<List<Integer>>() {})) .doesNotThrowAnyException(); }