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");
* 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);
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<NumberHolder<Integer>> 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<Auditable> events = new ArrayList<>();
ApplicationListener<AuditablePayloadEvent<String>> listener = events::add;
@ -93,6 +97,7 @@ class PayloadApplicationEventTests {
}
@Test
@SuppressWarnings("resource")
void testProgrammaticPayloadListener() {
List<String> events = new ArrayList<>();
ApplicationListener<PayloadApplicationEvent<String>> listener = ApplicationListener.forPayload(events::add);
@ -135,10 +140,7 @@ class PayloadApplicationEventTests {
static class NumberHolder<T extends Number> {
private 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");
* 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<MediaType> 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<MediaType> 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");

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");
* 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);