Suppress warnings in tests

This commit is contained in:
Sam Brannen 2022-01-03 16:11:15 +01:00
parent 97625e3658
commit 6555d3b42d
3 changed files with 26 additions and 17 deletions

View File

@ -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"); * 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.
@ -43,11 +43,12 @@ class PayloadApplicationEventTests {
PayloadApplicationEvent<NumberHolder<Integer>> event = new PayloadApplicationEvent<>(this, payload); PayloadApplicationEvent<NumberHolder<Integer>> event = new PayloadApplicationEvent<>(this, payload);
assertThat(event.getResolvableType()).satisfies(eventType -> { assertThat(event.getResolvableType()).satisfies(eventType -> {
assertThat(eventType.toClass()).isEqualTo(PayloadApplicationEvent.class); assertThat(eventType.toClass()).isEqualTo(PayloadApplicationEvent.class);
assertThat(eventType.getGenerics()).hasSize(1); assertThat(eventType.getGenerics())
assertThat(eventType.getGenerics()[0]).satisfies(bodyType -> { .hasSize(1)
assertThat(bodyType.toClass()).isEqualTo(NumberHolder.class); .allSatisfy(bodyType -> {
assertThat(bodyType.hasUnresolvableGenerics()).isTrue(); assertThat(bodyType.toClass()).isEqualTo(NumberHolder.class);
}); assertThat(bodyType.hasUnresolvableGenerics()).isTrue();
});
}); });
} }
@ -58,16 +59,18 @@ class PayloadApplicationEventTests {
PayloadApplicationEvent<NumberHolder<Integer>> event = new PayloadApplicationEvent<>(this, payload, payloadType); PayloadApplicationEvent<NumberHolder<Integer>> event = new PayloadApplicationEvent<>(this, payload, payloadType);
assertThat(event.getResolvableType()).satisfies(eventType -> { assertThat(event.getResolvableType()).satisfies(eventType -> {
assertThat(eventType.toClass()).isEqualTo(PayloadApplicationEvent.class); assertThat(eventType.toClass()).isEqualTo(PayloadApplicationEvent.class);
assertThat(eventType.getGenerics()).hasSize(1); assertThat(eventType.getGenerics())
assertThat(eventType.getGenerics()[0]).satisfies(bodyType -> { .hasSize(1)
assertThat(bodyType.toClass()).isEqualTo(NumberHolder.class); .allSatisfy(bodyType -> {
assertThat(bodyType.hasUnresolvableGenerics()).isFalse(); assertThat(bodyType.toClass()).isEqualTo(NumberHolder.class);
assertThat(bodyType.getGenerics()[0].toClass()).isEqualTo(Integer.class); assertThat(bodyType.hasUnresolvableGenerics()).isFalse();
}); assertThat(bodyType.getGenerics()[0].toClass()).isEqualTo(Integer.class);
});
}); });
} }
@Test @Test
@SuppressWarnings("resource")
void testEventClassWithInterface() { void testEventClassWithInterface() {
ApplicationContext ac = new AnnotationConfigApplicationContext(AuditableListener.class); ApplicationContext ac = new AnnotationConfigApplicationContext(AuditableListener.class);
@ -77,6 +80,7 @@ class PayloadApplicationEventTests {
} }
@Test @Test
@SuppressWarnings("resource")
void testProgrammaticEventListener() { void testProgrammaticEventListener() {
List<Auditable> events = new ArrayList<>(); List<Auditable> events = new ArrayList<>();
ApplicationListener<AuditablePayloadEvent<String>> listener = events::add; ApplicationListener<AuditablePayloadEvent<String>> listener = events::add;
@ -93,6 +97,7 @@ class PayloadApplicationEventTests {
} }
@Test @Test
@SuppressWarnings("resource")
void testProgrammaticPayloadListener() { void testProgrammaticPayloadListener() {
List<String> events = new ArrayList<>(); List<String> events = new ArrayList<>();
ApplicationListener<PayloadApplicationEvent<String>> listener = ApplicationListener.forPayload(events::add); ApplicationListener<PayloadApplicationEvent<String>> listener = ApplicationListener.forPayload(events::add);
@ -135,10 +140,7 @@ class PayloadApplicationEventTests {
static class NumberHolder<T extends Number> { static class NumberHolder<T extends Number> {
private T number;
public NumberHolder(T number) { public NumberHolder(T number) {
this.number = number;
} }
} }

View File

@ -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"); * 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.
@ -291,6 +291,7 @@ public class MediaTypeTests {
MediaType allXml = new MediaType("application", "*+xml"); MediaType allXml = new MediaType("application", "*+xml");
MediaType all = MediaType.ALL; MediaType all = MediaType.ALL;
@SuppressWarnings("deprecation")
Comparator<MediaType> comp = MediaType.SPECIFICITY_COMPARATOR; Comparator<MediaType> comp = MediaType.SPECIFICITY_COMPARATOR;
// equal // equal
@ -334,6 +335,7 @@ public class MediaTypeTests {
} }
@Test @Test
@SuppressWarnings("deprecation")
public void sortBySpecificityRelated() { public void sortBySpecificityRelated() {
MediaType audioBasic = new MediaType("audio", "basic"); MediaType audioBasic = new MediaType("audio", "basic");
MediaType audio = new MediaType("audio"); MediaType audio = new MediaType("audio");
@ -364,6 +366,7 @@ public class MediaTypeTests {
} }
@Test @Test
@SuppressWarnings("deprecation")
public void sortBySpecificityUnrelated() { public void sortBySpecificityUnrelated() {
MediaType audioBasic = new MediaType("audio", "basic"); MediaType audioBasic = new MediaType("audio", "basic");
MediaType audioWave = new MediaType("audio", "wave"); MediaType audioWave = new MediaType("audio", "wave");
@ -395,6 +398,7 @@ public class MediaTypeTests {
MediaType allXml = new MediaType("application", "*+xml"); MediaType allXml = new MediaType("application", "*+xml");
MediaType all = MediaType.ALL; MediaType all = MediaType.ALL;
@SuppressWarnings("deprecation")
Comparator<MediaType> comp = MediaType.QUALITY_VALUE_COMPARATOR; Comparator<MediaType> comp = MediaType.QUALITY_VALUE_COMPARATOR;
// equal // equal
@ -438,6 +442,7 @@ public class MediaTypeTests {
} }
@Test @Test
@SuppressWarnings("deprecation")
public void sortByQualityRelated() { public void sortByQualityRelated() {
MediaType audioBasic = new MediaType("audio", "basic"); MediaType audioBasic = new MediaType("audio", "basic");
MediaType audio = new MediaType("audio"); MediaType audio = new MediaType("audio");
@ -468,6 +473,7 @@ public class MediaTypeTests {
} }
@Test @Test
@SuppressWarnings("deprecation")
public void sortByQualityUnrelated() { public void sortByQualityUnrelated() {
MediaType audioBasic = new MediaType("audio", "basic"); MediaType audioBasic = new MediaType("audio", "basic");
MediaType audioWave = new MediaType("audio", "wave"); MediaType audioWave = new MediaType("audio", "wave");

View File

@ -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"); * 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.
@ -147,6 +147,7 @@ public class ProtobufHttpMessageConverterTests {
new ProtobufHttpMessageConverter.ProtobufJavaFormatSupport(), new ProtobufHttpMessageConverter.ProtobufJavaFormatSupport(),
this.extensionRegistry); this.extensionRegistry);
MockHttpOutputMessage outputMessage = new MockHttpOutputMessage(); MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();
@SuppressWarnings("deprecation")
MediaType contentType = MediaType.APPLICATION_JSON_UTF8; MediaType contentType = MediaType.APPLICATION_JSON_UTF8;
this.converter.write(this.testMsg, contentType, outputMessage); this.converter.write(this.testMsg, contentType, outputMessage);