Consistent handling of AssertProvider implementations

This commit is contained in:
Stéphane Nicoll 2024-02-20 10:19:19 +01:00
parent 46bd133892
commit 06a39f166e
5 changed files with 18 additions and 20 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -39,6 +39,10 @@ public class RuntimeHintsInvocations implements AssertProvider<RuntimeHintsInvoc
this.invocations = invocations;
}
/**
* Use {@code assertThat(invocations)} rather than calling this method
* directly.
*/
@Override
public RuntimeHintsInvocationsAssert assertThat() {
return new RuntimeHintsInvocationsAssert(this);

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -86,12 +86,10 @@ public final class ResourceFile extends DynamicFile implements AssertProvider<Re
}
/**
* AssertJ {@code assertThat} support.
* @deprecated use {@code assertThat(sourceFile)} rather than calling this
* method directly.
* Use {@code assertThat(sourceFile)} rather than calling this method
* directly.
*/
@Override
@Deprecated
public ResourceFileAssert assertThat() {
return new ResourceFileAssert(this);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -218,12 +218,10 @@ public final class SourceFile extends DynamicFile implements AssertProvider<Sour
}
/**
* AssertJ {@code assertThat} support.
* @deprecated use {@code assertThat(sourceFile)} rather than calling this
* method directly.
* Use {@code assertThat(sourceFile)} rather than calling this method
* directly.
*/
@Override
@Deprecated
public SourceFileAssert assertThat() {
return new SourceFileAssert(this);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -42,10 +42,9 @@ class ResourceFileTests {
}
@Test
@SuppressWarnings("deprecation")
void assertThatReturnsResourceFileAssert() {
ResourceFile file = ResourceFile.of("path", "test");
assertThat(file.assertThat()).isInstanceOf(ResourceFileAssert.class);
void assertThatUsesResourceFileAssert() {
ResourceFile file = ResourceFile.of("path", appendable -> appendable.append("test"));
assertThat(file).hasContent("test");
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -106,10 +106,9 @@ class SourceFileTests {
}
@Test
@SuppressWarnings("deprecation")
void assertThatReturnsAssert() {
void assertThatUseSourceFileAssert() {
SourceFile sourceFile = SourceFile.of(HELLO_WORLD);
assertThat(sourceFile.assertThat()).isInstanceOf(SourceFileAssert.class);
assertThat(sourceFile).hasContent(HELLO_WORLD);
}
@Test