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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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; this.invocations = invocations;
} }
/**
* Use {@code assertThat(invocations)} rather than calling this method
* directly.
*/
@Override @Override
public RuntimeHintsInvocationsAssert assertThat() { public RuntimeHintsInvocationsAssert assertThat() {
return new RuntimeHintsInvocationsAssert(this); 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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. * Use {@code assertThat(sourceFile)} rather than calling this method
* @deprecated use {@code assertThat(sourceFile)} rather than calling this * directly.
* method directly.
*/ */
@Override @Override
@Deprecated
public ResourceFileAssert assertThat() { public ResourceFileAssert assertThat() {
return new ResourceFileAssert(this); 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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. * Use {@code assertThat(sourceFile)} rather than calling this method
* @deprecated use {@code assertThat(sourceFile)} rather than calling this * directly.
* method directly.
*/ */
@Override @Override
@Deprecated
public SourceFileAssert assertThat() { public SourceFileAssert assertThat() {
return new SourceFileAssert(this); 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -42,10 +42,9 @@ class ResourceFileTests {
} }
@Test @Test
@SuppressWarnings("deprecation") void assertThatUsesResourceFileAssert() {
void assertThatReturnsResourceFileAssert() { ResourceFile file = ResourceFile.of("path", appendable -> appendable.append("test"));
ResourceFile file = ResourceFile.of("path", "test"); assertThat(file).hasContent("test");
assertThat(file.assertThat()).isInstanceOf(ResourceFileAssert.class);
} }
} }

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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -106,10 +106,9 @@ class SourceFileTests {
} }
@Test @Test
@SuppressWarnings("deprecation") void assertThatUseSourceFileAssert() {
void assertThatReturnsAssert() {
SourceFile sourceFile = SourceFile.of(HELLO_WORLD); SourceFile sourceFile = SourceFile.of(HELLO_WORLD);
assertThat(sourceFile.assertThat()).isInstanceOf(SourceFileAssert.class); assertThat(sourceFile).hasContent(HELLO_WORLD);
} }
@Test @Test