@Test public void mergeDefinitions_ThrowsIllegalArgumentExceptionOnInvalidFieldsDefinition() throws Exception { // Given JsonNode sourceDefinitions = mapper.readTree("{\"fields\": false, \"fieldFormatMap\": \"{\\\"foo\\\": {\\\"name\\\": \\\"fooOld\\\"}}\"}"); JsonNode stagemonitorDefinitions = mapper.readTree("{\"fields\": \"[{\\\"name\\\": \\\"fooField\\\", \\\"value\\\": \\\"new\\\"}]\", \"fieldFormatMap\": \"{\\\"foo\\\": {\\\"name\\\": \\\"fooNew\\\"}}\"}"); // Then assertThatIllegalArgumentException().isThrownBy(() -> JsonMerger.merge(sourceDefinitions, stagemonitorDefinitions, mergeStrategy)) .withMessage("error before decoding fields. Expected textual or null field, but encountered BOOLEAN"); }
@Test public void mergeDefinitions_ThrowsIllegalArgumentExceptionOnInvalidFieldFormatMapDefinition() throws Exception { // Given JsonNode sourceDefinitions = mapper.readTree("{\"fields\": \"[]\", \"fieldFormatMap\": false}"); JsonNode stagemonitorDefinitions = mapper.readTree("{\"fields\": \"[{\\\"name\\\": \\\"fooField\\\", \\\"value\\\": \\\"new\\\"}]\", \"fieldFormatMap\": \"{\\\"foo\\\": {\\\"name\\\": \\\"fooNew\\\"}}\"}"); // Then assertThatIllegalArgumentException().isThrownBy(() -> JsonMerger.merge(sourceDefinitions, stagemonitorDefinitions, mergeStrategy)) .withMessage("error before decoding fieldFormatMap. Expected textual or null field, but encountered BOOLEAN"); }
@Test public void mergeDefinitions_ThrowsIllegalArgumentExceptionOnInvalidFieldFormatMapType() throws Exception { // Given JsonNode sourceDefinitions = mapper.readTree("{\"fields\": \"[]\", \"fieldFormatMap\": \"[]\"}"); JsonNode stagemonitorDefinitions = mapper.readTree("{\"fields\": \"[{\\\"name\\\": \\\"fooField\\\", \\\"value\\\": \\\"new\\\"}]\", \"fieldFormatMap\": \"{\\\"foo\\\": {\\\"name\\\": \\\"fooNew\\\"}}\"}"); // Then assertThatIllegalArgumentException().isThrownBy(() -> JsonMerger.merge(sourceDefinitions, stagemonitorDefinitions, mergeStrategy)) .withMessage("error after decodingfieldFormatMap. Expected decoded type to be OBJECT, but encountered ARRAY"); }
@Test public void mergeDefinitions_ThrowsIllegalArgumentExceptionOnInvalidFieldsType() throws Exception { // Given JsonNode sourceDefinitions = mapper.readTree("{\"fields\": \"{}\", \"fieldFormatMap\": \"{\\\"foo\\\": {\\\"name\\\": \\\"fooOld\\\"}}\"}"); JsonNode stagemonitorDefinitions = mapper.readTree("{\"fields\": \"[{\\\"name\\\": \\\"fooField\\\", \\\"value\\\": \\\"new\\\"}]\", \"fieldFormatMap\": \"{\\\"foo\\\": {\\\"name\\\": \\\"fooNew\\\"}}\"}"); // Then assertThatIllegalArgumentException().isThrownBy(() -> JsonMerger.merge(sourceDefinitions, stagemonitorDefinitions, mergeStrategy)) .withMessage("error after decodingfields. Expected decoded type to be ARRAY, but encountered OBJECT"); }
@Test public void nMinusOne() { Mono<Integer> source = Mono.just(3); assertThatIllegalArgumentException() .isThrownBy(() -> source.repeat(-1, () -> true)) .withMessage("numRepeat >= 0 required"); }
@Test void testInvalidPropertyUpperCase() { assertThatIllegalArgumentException() .isThrownBy(() -> VersionProperty.of("Spring-boot.version")); }
@Test public void prefetchZero() { assertThatIllegalArgumentException() .isThrownBy(() -> new FluxMergeOrdered<Integer>(0, Queues.small(), Comparator.naturalOrder())) .withMessage("prefetch > 0 required but it was 0"); }
@Test public void whenSettingNullGrantedAuthoritiesConverter() { assertThatIllegalArgumentException() .isThrownBy(() -> this.jwtAuthenticationConverter.setJwtGrantedAuthoritiesConverter(null)) .withMessage("jwtGrantedAuthoritiesConverter cannot be null"); }
@Test public void whenConstructingWithInvalidConverter() { assertThatIllegalArgumentException() .isThrownBy(() -> new ReactiveJwtGrantedAuthoritiesConverterAdapter(null)) .withMessage("grantedAuthoritiesConverter cannot be null"); }
@Test public void prefetchNegative() { assertThatIllegalArgumentException() .isThrownBy(() -> new FluxMergeOrdered<Integer>(-1, Queues.small(), Comparator.naturalOrder())) .withMessage("prefetch > 0 required but it was -1"); }
@Test public void whenSettingNullGrantedAuthoritiesConverter() { assertThatIllegalArgumentException() .isThrownBy(() -> this.jwtAuthenticationConverter.setJwtGrantedAuthoritiesConverter(null)) .withMessage("jwtGrantedAuthoritiesConverter cannot be null"); }
@Test public void rejectPrefetchZero() { assertThatIllegalArgumentException() .isThrownBy(() -> new ParallelMergeOrdered<>(null, 0, null, null)) .withMessage("prefetch > 0 required but it was 0"); }
@Test public void rejectPrefetchNegative() { assertThatIllegalArgumentException() .isThrownBy(() -> new ParallelMergeOrdered<>(null,-1, null, null)) .withMessage("prefetch > 0 required but it was -1"); }
@Test void generateIdWithNoArtifactId() { Dependency dependency = new Dependency(); dependency.setGroupId("foo"); assertThatIllegalArgumentException().isThrownBy(dependency::generateId); }
@Test void testInvalidPropertyIllegalCharacter() { assertThatIllegalArgumentException() .isThrownBy(() -> VersionProperty.of("spring-boot_version")) .withMessageContaining("Unsupported character"); }
@Test void generateIdWithNoGroupId() { Dependency dependency = new Dependency(); dependency.setArtifactId("bar"); assertThatIllegalArgumentException().isThrownBy(dependency::generateId); }
@Test public void mainSubscribersDifferentCountInners() { CoreSubscriber<? super Integer> actual = new LambdaSubscriber<>(null, null, null, null); FluxMergeOrdered.MergeOrderedMainProducer<Integer> test = new FluxMergeOrdered.MergeOrderedMainProducer<Integer>(actual, Comparator.naturalOrder(), 123, 4); assertThatIllegalArgumentException() .isThrownBy(() -> { @SuppressWarnings("unchecked") final Publisher<Integer>[] sources = new Publisher[3]; test.subscribe(sources); }) .withMessage("must subscribe with 4 sources"); }
@Test void expandLinkMissingVariable() { Link link = Link.create("reference", "https://example.com/{a}/2/{b}"); link.resolve(); assertThatIllegalArgumentException() .isThrownBy(() -> link.expand(Collections.singletonMap("a", "test"))) .withMessageContaining("missing value for 'b'"); }
@Test public void nMinusOne() { Flux<Integer> source = Flux.just(1, 2, 3); assertThatIllegalArgumentException() .isThrownBy(() -> source.repeat(-1, () -> true)) .withMessage("numRepeat >= 0 required"); }
@Test void addTwoDependenciesWithSameId() { Dependency dependency = Dependency.withId("conflict"); Dependency dependency2 = Dependency.withId("conflict"); DependenciesCapability capability = createDependenciesCapability("foo", dependency, dependency2); assertThatIllegalArgumentException().isThrownBy(capability::validate) .withMessageContaining("conflict"); }