diff --git a/spring-context/src/test/java/org/springframework/context/event/PayloadApplicationEventTests.java b/spring-context/src/test/java/org/springframework/context/event/PayloadApplicationEventTests.java index 8fb78ceda8..42fb935e7f 100644 --- a/spring-context/src/test/java/org/springframework/context/event/PayloadApplicationEventTests.java +++ b/spring-context/src/test/java/org/springframework/context/event/PayloadApplicationEventTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2022 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. @@ -43,11 +43,12 @@ class PayloadApplicationEventTests { PayloadApplicationEvent> event = new PayloadApplicationEvent<>(this, payload); assertThat(event.getResolvableType()).satisfies(eventType -> { assertThat(eventType.toClass()).isEqualTo(PayloadApplicationEvent.class); - assertThat(eventType.getGenerics()).hasSize(1); - assertThat(eventType.getGenerics()[0]).satisfies(bodyType -> { - assertThat(bodyType.toClass()).isEqualTo(NumberHolder.class); - assertThat(bodyType.hasUnresolvableGenerics()).isTrue(); - }); + assertThat(eventType.getGenerics()) + .hasSize(1) + .allSatisfy(bodyType -> { + assertThat(bodyType.toClass()).isEqualTo(NumberHolder.class); + assertThat(bodyType.hasUnresolvableGenerics()).isTrue(); + }); }); } @@ -58,16 +59,18 @@ class PayloadApplicationEventTests { PayloadApplicationEvent> event = new PayloadApplicationEvent<>(this, payload, payloadType); assertThat(event.getResolvableType()).satisfies(eventType -> { assertThat(eventType.toClass()).isEqualTo(PayloadApplicationEvent.class); - assertThat(eventType.getGenerics()).hasSize(1); - assertThat(eventType.getGenerics()[0]).satisfies(bodyType -> { - assertThat(bodyType.toClass()).isEqualTo(NumberHolder.class); - assertThat(bodyType.hasUnresolvableGenerics()).isFalse(); - assertThat(bodyType.getGenerics()[0].toClass()).isEqualTo(Integer.class); - }); + assertThat(eventType.getGenerics()) + .hasSize(1) + .allSatisfy(bodyType -> { + assertThat(bodyType.toClass()).isEqualTo(NumberHolder.class); + assertThat(bodyType.hasUnresolvableGenerics()).isFalse(); + assertThat(bodyType.getGenerics()[0].toClass()).isEqualTo(Integer.class); + }); }); } @Test + @SuppressWarnings("resource") void testEventClassWithInterface() { ApplicationContext ac = new AnnotationConfigApplicationContext(AuditableListener.class); @@ -77,6 +80,7 @@ class PayloadApplicationEventTests { } @Test + @SuppressWarnings("resource") void testProgrammaticEventListener() { List events = new ArrayList<>(); ApplicationListener> listener = events::add; @@ -93,6 +97,7 @@ class PayloadApplicationEventTests { } @Test + @SuppressWarnings("resource") void testProgrammaticPayloadListener() { List events = new ArrayList<>(); ApplicationListener> listener = ApplicationListener.forPayload(events::add); @@ -135,10 +140,7 @@ class PayloadApplicationEventTests { static class NumberHolder { - private T number; - public NumberHolder(T number) { - this.number = number; } } diff --git a/spring-web/src/test/java/org/springframework/http/MediaTypeTests.java b/spring-web/src/test/java/org/springframework/http/MediaTypeTests.java index 9c14505845..190bdf82e8 100644 --- a/spring-web/src/test/java/org/springframework/http/MediaTypeTests.java +++ b/spring-web/src/test/java/org/springframework/http/MediaTypeTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2022 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. @@ -291,6 +291,7 @@ public class MediaTypeTests { MediaType allXml = new MediaType("application", "*+xml"); MediaType all = MediaType.ALL; + @SuppressWarnings("deprecation") Comparator comp = MediaType.SPECIFICITY_COMPARATOR; // equal @@ -334,6 +335,7 @@ public class MediaTypeTests { } @Test + @SuppressWarnings("deprecation") public void sortBySpecificityRelated() { MediaType audioBasic = new MediaType("audio", "basic"); MediaType audio = new MediaType("audio"); @@ -364,6 +366,7 @@ public class MediaTypeTests { } @Test + @SuppressWarnings("deprecation") public void sortBySpecificityUnrelated() { MediaType audioBasic = new MediaType("audio", "basic"); MediaType audioWave = new MediaType("audio", "wave"); @@ -395,6 +398,7 @@ public class MediaTypeTests { MediaType allXml = new MediaType("application", "*+xml"); MediaType all = MediaType.ALL; + @SuppressWarnings("deprecation") Comparator comp = MediaType.QUALITY_VALUE_COMPARATOR; // equal @@ -438,6 +442,7 @@ public class MediaTypeTests { } @Test + @SuppressWarnings("deprecation") public void sortByQualityRelated() { MediaType audioBasic = new MediaType("audio", "basic"); MediaType audio = new MediaType("audio"); @@ -468,6 +473,7 @@ public class MediaTypeTests { } @Test + @SuppressWarnings("deprecation") public void sortByQualityUnrelated() { MediaType audioBasic = new MediaType("audio", "basic"); MediaType audioWave = new MediaType("audio", "wave"); diff --git a/spring-web/src/test/java/org/springframework/http/converter/protobuf/ProtobufHttpMessageConverterTests.java b/spring-web/src/test/java/org/springframework/http/converter/protobuf/ProtobufHttpMessageConverterTests.java index 6d89057ea8..92705a4dcb 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/protobuf/ProtobufHttpMessageConverterTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/protobuf/ProtobufHttpMessageConverterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2022 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. @@ -147,6 +147,7 @@ public class ProtobufHttpMessageConverterTests { new ProtobufHttpMessageConverter.ProtobufJavaFormatSupport(), this.extensionRegistry); MockHttpOutputMessage outputMessage = new MockHttpOutputMessage(); + @SuppressWarnings("deprecation") MediaType contentType = MediaType.APPLICATION_JSON_UTF8; this.converter.write(this.testMsg, contentType, outputMessage);