Skip to content

Commit

Permalink
cosmetic: eliminate code warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanseifert committed Jul 4, 2024
1 parent a01c9da commit 0a851a5
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public ComponentPropertyResolver(@NotNull ComponentContext wcmComponentContext,
* @param page Content page
* @deprecated Please use {@link ComponentPropertyResolverFactory}.
*/
@Deprecated
@Deprecated(since = "1.6.0")
public ComponentPropertyResolver(@NotNull Page page) {
this(page, null);
}
Expand All @@ -158,7 +158,7 @@ public ComponentPropertyResolver(@NotNull Page page) {
* @param resource Content resource
* @deprecated Please use {@link ComponentPropertyResolverFactory}.
*/
@Deprecated
@Deprecated(since = "1.6.0")
public ComponentPropertyResolver(@NotNull Resource resource) {
this(resource, null);
}
Expand All @@ -170,7 +170,7 @@ public ComponentPropertyResolver(@NotNull Resource resource) {
* If this is not the case, try to find the closest parent resource which has a resource type.
* @deprecated Please use {@link ComponentPropertyResolverFactory}.
*/
@Deprecated
@Deprecated(since = "1.6.0")
public ComponentPropertyResolver(@NotNull Resource resource, boolean ensureResourceType) {
this(resource, ensureResourceType, null);
}
Expand All @@ -180,7 +180,7 @@ public ComponentPropertyResolver(@NotNull Resource resource, boolean ensureResou
* @param wcmComponentContext WCM component context
* @deprecated Please use {@link ComponentPropertyResolverFactory}.
*/
@Deprecated
@Deprecated(since = "1.6.0")
public ComponentPropertyResolver(@NotNull ComponentContext wcmComponentContext) {
this(wcmComponentContext, null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ private FileExtension() {
* @return true if image
* @deprecated Use <code>io.wcm.handler.media.MediaFileType.isImage</code> instead.
*/
@Deprecated
@Deprecated(since = "1.5.0")
public static boolean isImage(@Nullable String fileExtension) {
if (StringUtils.isEmpty(fileExtension)) {
return false;
Expand All @@ -165,7 +165,7 @@ public static boolean isImage(@Nullable String fileExtension) {
* @return Image file extensions for standard image formats supported by web browsers and AEM Layer implementations.
* @deprecated Use <code>io.wcm.handler.media.MediaFileType.getImageFileExtensions</code> instead.
*/
@Deprecated
@Deprecated(since = "1.5.0")
public static @NotNull Set<String> getImageFileExtensions() {
return Collections.unmodifiableSet(IMAGE_FILE_EXTENSIONS);
}
Expand All @@ -176,7 +176,7 @@ public static boolean isImage(@Nullable String fileExtension) {
* @return true if flash
* @deprecated Use <code>io.wcm.handler.media.MediaFileType.isFlash</code> instead.
*/
@Deprecated
@Deprecated(since = "1.5.0")
public static boolean isFlash(@Nullable String fileExtension) {
if (StringUtils.isEmpty(fileExtension)) {
return false;
Expand All @@ -188,7 +188,7 @@ public static boolean isFlash(@Nullable String fileExtension) {
* @return Flash file extensions
* @deprecated Use <code>io.wcm.handler.media.MediaFileType.getFlashFileExtensions</code> instead.
*/
@Deprecated
@Deprecated(since = "1.5.0")
public static @NotNull Set<String> getFlashFileExtensions() {
return Collections.unmodifiableSet(FLASH_FILE_EXTENSIONS);
}
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/io/wcm/wcm/commons/util/RunMode.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ private RunMode() {
* gets only active if a configuration is available. Such a configuration can be put into the repository
* for the specific run mode.
*/
@Deprecated
@Deprecated(since = "1.0.4")
public static boolean is(Set<String> runModes, String... expectedRunModes) {
if (runModes != null && expectedRunModes != null) {
for (String expectedRunMode : expectedRunModes) {
Expand All @@ -82,7 +82,7 @@ public static boolean is(Set<String> runModes, String... expectedRunModes) {
* gets only active if a configuration is available. Such a configuration can be put into the repository
* for the specific run mode.
*/
@Deprecated
@Deprecated(since = "1.0.4")
public static boolean isAuthor(Set<String> runModes) {
return is(runModes, AUTHOR);
}
Expand All @@ -96,7 +96,7 @@ public static boolean isAuthor(Set<String> runModes) {
* gets only active if a configuration is available. Such a configuration can be put into the repository
* for the specific run mode.
*/
@Deprecated
@Deprecated(since = "1.0.4")
public static boolean isPublish(Set<String> runModes) {
return is(runModes, PUBLISH);
}
Expand All @@ -117,7 +117,7 @@ public static boolean isPublish(Set<String> runModes) {
* gets only active if a configuration is available. Such a configuration can be put into the repository
* for the specific run mode.
*/
@Deprecated
@Deprecated(since = "1.0.4")
public static boolean disableIfNoRunModeActive(Set<String> runModes, String[] allowedRunModes,
ComponentContext componentContext, Logger log) {

Expand Down Expand Up @@ -162,7 +162,7 @@ else if (log.isDebugEnabled()) {
* gets only active if a configuration is available. Such a configuration can be put into the repository
* for the specific run mode.
*/
@Deprecated
@Deprecated(since = "1.0.4")
public static boolean disableIfNotAuthor(Set<String> runModes, ComponentContext componentContext, Logger log) {
return disableIfNoRunModeActive(runModes, new String[] {
AUTHOR
Expand All @@ -184,7 +184,7 @@ public static boolean disableIfNotAuthor(Set<String> runModes, ComponentContext
* gets only active if a configuration is available. Such a configuration can be put into the repository
* for the specific run mode.
*/
@Deprecated
@Deprecated(since = "1.0.4")
public static boolean disableIfNotPublish(Set<String> runModes, ComponentContext componentContext, Logger log) {
return disableIfNoRunModeActive(runModes, new String[] {
PUBLISH
Expand Down
9 changes: 6 additions & 3 deletions src/test/java/io/wcm/wcm/commons/caching/CacheHeaderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,23 +136,26 @@ void testSetExpires() {
}

@Test
@SuppressWarnings("java:S2699") // validation via doAnswer
void testSetExpiresSeconds() {
doAnswer(new ValidateDateHeaderAnswer(200 * DateUtils.MILLIS_PER_SECOND))
.when(response).setHeader(eq(CacheHeader.HEADER_EXPIRES), anyString());
.when(response).setHeader(eq(CacheHeader.HEADER_EXPIRES), anyString());
CacheHeader.setExpiresSeconds(response, 200);
}

@Test
@SuppressWarnings("java:S2699") // validation via doAnswer
void testSetExpiresHours() {
doAnswer(new ValidateDateHeaderAnswer(15 * DateUtils.MILLIS_PER_HOUR))
.when(response).setHeader(eq(CacheHeader.HEADER_EXPIRES), anyString());
.when(response).setHeader(eq(CacheHeader.HEADER_EXPIRES), anyString());
CacheHeader.setExpiresHours(response, 15);
}

@Test
@SuppressWarnings("java:S2699") // validation via doAnswer
void testSetExpiresDays() {
doAnswer(new ValidateDateHeaderAnswer(20 * DateUtils.MILLIS_PER_DAY))
.when(response).setHeader(eq(CacheHeader.HEADER_EXPIRES), anyString());
.when(response).setHeader(eq(CacheHeader.HEADER_EXPIRES), anyString());
CacheHeader.setExpiresDays(response, 20);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ class FileExtensionTest {

@Test
@SuppressWarnings("deprecation")
void testIsImage() throws Exception {
void testIsImage() {
assertTrue(FileExtension.isImage("png"));
assertFalse(FileExtension.isImage(null));
}

@Test
@SuppressWarnings("deprecation")
void testIsFlash() throws Exception {
void testIsFlash() {
assertTrue(FileExtension.isFlash("swf"));
assertFalse(FileExtension.isFlash(null));
}
Expand Down

0 comments on commit 0a851a5

Please sign in to comment.