public static void assertThatAttributeIs(ProtobufSystemInfo.Section section, String key, boolean expectedValue) { ProtobufSystemInfo.Attribute value = attribute(section, key); assertThat(value).as(key).isNotNull(); assertThat(value.getBooleanValue()).isEqualTo(expectedValue); }
public static void assertThatAttributeIs(ProtobufSystemInfo.Section section, String key, long expectedValue) { ProtobufSystemInfo.Attribute value = attribute(section, key); assertThat(value).as(key).isNotNull(); assertThat(value.getLongValue()).isEqualTo(expectedValue); } }
public static void assertThatAttributeIs(ProtobufSystemInfo.Section section, String key, String expectedValue) { ProtobufSystemInfo.Attribute value = attribute(section, key); assertThat(value).as(key).isNotNull(); assertThat(value.getStringValue()).isEqualTo(expectedValue); }
public void verify(UserDto userDto, boolean root, long updatedAt) { Map<String, Object> row = db.selectFirst("select is_root as \"isRoot\", updated_at as \"updatedAt\" from users where login = '" + userDto.getLogin() + "'"); Object isRoot = row.get("isRoot"); assertThat(isRoot) .as("Root flag of user '%s' is same as when created", userDto.getLogin()) .isEqualTo(isRoot instanceof Long ? toLong(root) : root); assertThat(row.get("updatedAt")) .as("UpdatedAt of user '%s' has not changed since created") .isEqualTo(updatedAt); }
public void verify(UserDto userDto, boolean root) { Map<String, Object> row = db.selectFirst("select is_root as \"isRoot\", updated_at as \"updatedAt\" from users where login = '" + userDto.getLogin() + "'"); Object isRoot = row.get("isRoot"); assertThat(isRoot) .as("Root flag of user '%s' is '%s'", userDto.getLogin(), root) .isEqualTo(isRoot instanceof Long ? toLong(root) : root); assertThat(row.get("updatedAt")) .as("UpdatedAt of user '%s' has changed since insertion", userDto.getLogin()) .isNotEqualTo(userDto.getUpdatedAt()); }
@Test public void testLogout() throws Exception { SecurityContextHolder.getContext().setAuthentication(this.auth); this.module.login(); assertThat(this.module.logout()).as("Should return true as it succeeds").isTrue(); assertThat(this.module.getAuthentication()).as("Authentication should be null") .isNull(); assertThat(this.subject.getPrincipals().contains(this.auth)) .withFailMessage( "Principals should not contain the authentication after logout") .isFalse(); }
@Test public void monoFromFluxItselfMonoToFlux_fuseable() { Mono<String> original = Mono.just("foo").map(v -> v + "bar"); Flux<String> firstConversion = original.flux(); Mono<String> secondConversion = Mono.from(firstConversion); assertThat(original).isInstanceOf(Fuseable.class); assertThat(secondConversion).isInstanceOf(Fuseable.class); assertThat(secondConversion.block()).isEqualTo("foobar"); assertThat(secondConversion).as("conversions negated").isSameAs(original); }
@Test public void getAllValuesCorrespondToArray() { Object[] array = full.toArray(); for (int i = 0; i < array.length; i++) { assertThat(full.get(i)).as("element " + i) .isEqualTo(array[i]); } }
@Test public void getAllValuesCorrespondToArray() { Object[] array = full.toArray(); for (int i = 0; i < array.length; i++) { assertThat(full.get(i)).as("element " + i).isEqualTo(array[i]); } }
@Test public void testBadPassword() { try { jaasProvider.authenticate(new UsernamePasswordAuthenticationToken("user", "asdf")); fail("LoginException should have been thrown for the bad password"); } catch (AuthenticationException e) { } assertThat(eventCheck.failedEvent).as("Failure event not fired").isNotNull(); assertThat(eventCheck.failedEvent.getException()).withFailMessage("Failure event exception was null").isNotNull(); assertThat(eventCheck.successEvent).as("Success event was fired").isNull(); }
@Test public void getAllValuesCorrespondToArray() { Object[] array = full.toArray(); for (int i = 0; i < array.length; i++) { assertThat(full.get(i)).as("element " + i).isEqualTo(array[i]); } }
@Test public void testBadUser() { try { jaasProvider.authenticate(new UsernamePasswordAuthenticationToken("asdf", "password")); fail("LoginException should have been thrown for the bad user"); } catch (AuthenticationException e) { } assertThat(eventCheck.failedEvent).as("Failure event not fired").isNotNull(); assertThat(eventCheck.failedEvent.getException()).withFailMessage("Failure event exception was null").isNotNull(); assertThat(eventCheck.successEvent).as("Success event was fired").isNull(); }
@Test public void monoFromFluxThatIsItselfFromMono_scalarCallableNotOptimized() { Mono<String> original = Mono.just("foo"); Flux<String> firstConversion = Flux.from(original); Mono<String> secondConversion = Mono.from(firstConversion); assertThat(secondConversion.block()).isEqualTo("foo"); assertThat(secondConversion).as("conversions not negated but equivalent") .isNotSameAs(original) .hasSameClassAs(original); }
@Test public void monoFromFluxItselfMonoToFlux_scalarCallableNotOptimized() { Mono<String> original = Mono.just("foo"); Flux<String> firstConversion = original.flux(); Mono<String> secondConversion = Mono.from(firstConversion); assertThat(secondConversion.block()).isEqualTo("foo"); assertThat(secondConversion).as("conversions not negated but equivalent") .isNotSameAs(original) .hasSameClassAs(original); }
@Test public void monoFromFluxItselfMonoToFlux() { Mono<String> original = Mono.just("foo").hide(); Flux<String> firstConversion = original.flux(); Mono<String> secondConversion = Mono.from(firstConversion); assertThat(secondConversion.block()).isEqualTo("foo"); assertThat(secondConversion).as("conversions negated").isSameAs(original); }
@Test public void schedulerDecoratorRemoveUnknownIgnored() { assertThat(Schedulers.removeExecutorServiceDecorator("keyfoo")) .as("unknown decorator ignored") .isNull(); }
@Test public void scanCancelInner() { CoreSubscriber<? super Integer> actual = new LambdaSubscriber<>(null, e -> {}, null, null); UsingWhenSubscriber<Integer, String> up = new UsingWhenSubscriber<>(actual, "RESOURCE", Mono::just, Mono::just, Mono::just, null); final Subscription parent = Operators.emptySubscription(); up.onSubscribe(parent); FluxUsingWhen.CancelInner op = new FluxUsingWhen.CancelInner(up); assertThat(op.scan(Attr.PARENT)).as("PARENT").isSameAs(up); assertThat(op.scan(Attr.ACTUAL)).as("ACTUAL").isSameAs(up.actual); assertThat(op.scanUnsafe(Attr.PREFETCH)).as("PREFETCH not supported").isNull(); }
@Test public void scanOperator() { Flux<?> source = Flux.empty(); FluxOnAssembly<?> test = new FluxOnAssembly<>(source, new AssemblySnapshot(null, Traces.callSiteSupplierFactory.get())); assertThat(test.scan(Scannable.Attr.ACTUAL_METADATA)).as("ACTUAL_METADATA").isTrue(); assertThat(test.scan(Scannable.Attr.PREFETCH)).as("PREFETCH").isEqualTo(-1); assertThat(test.scan(Scannable.Attr.PARENT)).as("PARENT").isSameAs(source); }
@Test public void selectMeasure_map_fields() { MetricDto metric = db.measures().insertMetric(); ComponentDto project = db.components().insertPrivateProject(); ComponentDto file = db.components().insertComponent(newFileDto(project)); underTest.insert(db.getSession(), newLiveMeasure(file, metric).setValue(3.14).setVariation(0.1).setData("text_value")); LiveMeasureDto result = underTest.selectMeasure(db.getSession(), file.uuid(), metric.getKey()).orElseThrow(() -> new IllegalArgumentException("Measure not found")); assertThat(result).as("Fail to map fields of %s", result.toString()).extracting( LiveMeasureDto::getProjectUuid, LiveMeasureDto::getComponentUuid, LiveMeasureDto::getMetricId, LiveMeasureDto::getValue, LiveMeasureDto::getVariation, LiveMeasureDto::getDataAsString, LiveMeasureDto::getTextValue) .contains(project.uuid(), file.uuid(), metric.getId(), 3.14, 0.1, "text_value", "text_value"); }