Skip to content

Commit

Permalink
Fix warnings in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SgtSilvio committed Nov 15, 2023
1 parent 65ba794 commit 7cc01bd
Show file tree
Hide file tree
Showing 17 changed files with 37 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,6 @@ void modifyMethods_throwUOE() {

@ParameterizedTest
@MethodSource("numberedList")
@SuppressWarnings("ResultOfMethodCallIgnored")
void get(final @NotNull ImmutableList<String> list) {
assertThrows(IndexOutOfBoundsException.class, () -> list.get(-1));
for (int i = 0; i < list.size(); i++) {
Expand Down Expand Up @@ -388,10 +387,10 @@ void contains(final @NotNull ImmutableList<String> list) {
@SuppressWarnings("CollectionAddedToSelf")
void containsAll(final @NotNull ImmutableList<String> list) {
assertTrue(list.containsAll(list));
assertTrue(list.containsAll(ImmutableList.of()));
assertTrue(list.containsAll(ImmutableList.builder().addAll(list).build()));
assertTrue(list.containsAll(ImmutableList.<String>of()));
assertTrue(list.containsAll(ImmutableList.<String>builder().addAll(list).build()));
assertFalse(list.containsAll(ImmutableList.of("x")));
assertFalse(list.containsAll(ImmutableList.builder().addAll(list).add("x").build()));
assertFalse(list.containsAll(ImmutableList.<String>builder().addAll(list).add("x").build()));
}

@ParameterizedTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1874,7 +1874,7 @@ private void testDisconnect(final @NotNull Mqtt5DisconnectReasonCode reasonCode)
}

private static final byte PROPERTIES_VALID_LENGTH = 119;
private static final @NotNull byte[] PROPERTIES_VALID = {
private static final byte @NotNull [] PROPERTIES_VALID = {
// session expiry interval
0x11, 0, 0, 0, 10,
// receive maximum
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ private void testDisconnect(final @NotNull Mqtt5DisconnectReasonCode reasonCode)
}

private final int PROPERTIES_VALID_LENGTH = 71;
private final @NotNull byte[] PROPERTIES_VALID = {
private final byte @NotNull [] PROPERTIES_VALID = {
// session expiry interval
0x11, 0, 0, 0, 10,
// reason string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ private void testDisconnect(final @NotNull Mqtt5DisconnectReasonCode reasonCode)
}

private static final int PROPERTIES_VALID_LENGTH = 54;
private static final @NotNull byte[] PROPERTIES_VALID = {
private static final byte @NotNull [] PROPERTIES_VALID = {
// reason string
0x1F, 0, 7, 's', 'u', 'c', 'c', 'e', 's', 's',
// user properties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ private void testDisconnect(final @NotNull Mqtt5DisconnectReasonCode reasonCode)
}

private static final int PROPERTIES_VALID_LENGTH = 54;
private static final @NotNull byte[] PROPERTIES_VALID = {
private static final byte @NotNull [] PROPERTIES_VALID = {
// reason string
0x1F, 0, 7, 's', 'u', 'c', 'c', 'e', 's', 's',
// user properties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,13 +401,13 @@ void decode_nullUserProperty_returnsNull() {
decodeNok(encoded, Mqtt5DisconnectReasonCode.MALFORMED_PACKET);
}

private @NotNull MqttPubRec decodeOk(final @NotNull byte[] encoded) {
private @NotNull MqttPubRec decodeOk(final byte @NotNull [] encoded) {
final MqttPubRec pubRec = decode(encoded);
assertNotNull(pubRec);
return pubRec;
}

private void decodeNok(final @NotNull byte[] encoded, final @NotNull Mqtt5DisconnectReasonCode reasonCode) {
private void decodeNok(final byte @NotNull [] encoded, final @NotNull Mqtt5DisconnectReasonCode reasonCode) {
final MqttPubRec pubRec = decode(encoded);
assertNull(pubRec);

Expand All @@ -418,7 +418,7 @@ private void decodeNok(final @NotNull byte[] encoded, final @NotNull Mqtt5Discon
createChannel();
}

private @Nullable MqttPubRec decode(final @NotNull byte[] encoded) {
private @Nullable MqttPubRec decode(final byte @NotNull [] encoded) {
final ByteBuf byteBuf = channel.alloc().buffer();
byteBuf.writeBytes(encoded);
channel.writeInbound(byteBuf);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,13 +341,13 @@ void decode_nullReasonString_returnsNull() {
decodeNok(encoded, MALFORMED_PACKET);
}

private @NotNull MqttPubRel decodeOk(final @NotNull byte[] encoded) {
private @NotNull MqttPubRel decodeOk(final byte @NotNull [] encoded) {
final MqttPubRel pubRel = decode(encoded);
assertNotNull(pubRel);
return pubRel;
}

private void decodeNok(final @NotNull byte[] encoded, final @NotNull Mqtt5DisconnectReasonCode reasonCode) {
private void decodeNok(final byte @NotNull [] encoded, final @NotNull Mqtt5DisconnectReasonCode reasonCode) {
final MqttPubRel pubRel = decode(encoded);
assertNull(pubRel);

Expand All @@ -358,7 +358,7 @@ private void decodeNok(final @NotNull byte[] encoded, final @NotNull Mqtt5Discon
createChannel();
}

private @Nullable MqttPubRel decode(final @NotNull byte[] encoded) {
private @Nullable MqttPubRel decode(final byte @NotNull [] encoded) {
final ByteBuf byteBuf = channel.alloc().buffer();
byteBuf.writeBytes(encoded);
channel.writeInbound(byteBuf);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -448,13 +448,13 @@ void encode_propertyIdentifierLessThanZero_returnsNull() {
}

@NotNull
private MqttSubAck decodeOk(final @NotNull byte[] encoded) {
private MqttSubAck decodeOk(final byte @NotNull [] encoded) {
final MqttSubAck subAck = decode(encoded);
assertNotNull(subAck);
return subAck;
}

private void decodeNok(final @NotNull byte[] encoded, final @NotNull Mqtt5DisconnectReasonCode reasonCode) {
private void decodeNok(final byte @NotNull [] encoded, final @NotNull Mqtt5DisconnectReasonCode reasonCode) {
final MqttSubAck subAck = decode(encoded);
assertNull(subAck);

Expand All @@ -466,7 +466,7 @@ private void decodeNok(final @NotNull byte[] encoded, final @NotNull Mqtt5Discon
}

@Nullable
private MqttSubAck decode(final @NotNull byte[] encoded) {
private MqttSubAck decode(final byte @NotNull [] encoded) {
final ByteBuf byteBuf = channel.alloc().buffer();
byteBuf.writeBytes(encoded);
channel.writeInbound(byteBuf);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ void encode_maximumPacketSizeExceededByUserProperties_omitUserPropertiesAndReaso
encode(maxPacket.getWithOmittedUserPropertiesAndReasonString(), auth);
}

private void encode(final @NotNull byte[] expected, final @NotNull MqttAuth auth) {
private void encode(final byte @NotNull [] expected, final @NotNull MqttAuth auth) {
encode(auth, expected);
}

Expand All @@ -249,7 +249,7 @@ private void encodeNok(
}

@SuppressWarnings("NullabilityAnnotations")
private class MaximumPacketBuilder {
private static class MaximumPacketBuilder {

private ImmutableList.Builder<MqttUserPropertyImpl> userPropertiesBuilder;
final MqttUserPropertyImpl userProperty =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ void encode_propertyLengthExceedsMax_throwsEncoderException() {
encodeNok(connectWrapper, EncoderException.class, "variable byte integer size exceeded for property length");
}

private void encode(final @NotNull byte[] expected, final @NotNull MqttStatefulConnect connectWrapper) {
private void encode(final byte @NotNull [] expected, final @NotNull MqttStatefulConnect connectWrapper) {
encode(connectWrapper, expected);
}

Expand All @@ -528,7 +528,7 @@ private void encodeNok(
}

@SuppressWarnings("NullabilityAnnotations")
private class MaximumPacketBuilder {
private static class MaximumPacketBuilder {

private ImmutableList.Builder<MqttUserPropertyImpl> userPropertiesBuilder;
final @NotNull MqttUserPropertyImpl userProperty =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ void encode_propertyLengthExceeded_omitReasonString() {
expected.release();
}

private void encode(final @NotNull byte[] expected, final @NotNull MqttDisconnect disconnect) {
private void encode(final byte @NotNull [] expected, final @NotNull MqttDisconnect disconnect) {
encode(disconnect, expected);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ void encode_reasonCodes(final @NotNull Mqtt5PubAckReasonCode reasonCode) {
encode(expected, pubAck);
}

private void encode(final @NotNull byte[] expected, final @NotNull MqttPubAck pubAck) {
private void encode(final byte @NotNull [] expected, final @NotNull MqttPubAck pubAck) {
encode(pubAck, expected);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,14 +371,14 @@ void encode_maximumPacketSizeExceeded_throws() {
"SUBSCRIBE exceeded maximum packet size, minimal possible encoded length: 268435461, maximum: 268435460"));
}

private void encode(final @NotNull byte[] expected, final MqttSubscribe subscribe, final int packetIdentifier) {
private void encode(final byte @NotNull [] expected, final MqttSubscribe subscribe, final int packetIdentifier) {
final MqttStatefulSubscribe subscribeInternal =
subscribe.createStateful(packetIdentifier, MqttStatefulSubscribe.DEFAULT_NO_SUBSCRIPTION_IDENTIFIER);
encodeInternal(expected, subscribeInternal);
}

private void encodeInternal(
final @NotNull byte[] expected, final @NotNull MqttStatefulSubscribe subscribeInternal) {
final byte @NotNull [] expected, final @NotNull MqttStatefulSubscribe subscribeInternal) {

encode(subscribeInternal, expected);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ void encode_propertyLengthExceeded_omitUserProperties() {
}

private void encodeUnsubscribe(
final @NotNull byte[] expected,
final byte @NotNull [] expected,
final @NotNull MqttUserPropertiesImpl userProperties,
final @NotNull ImmutableList<MqttTopicFilterImpl> topicFilters) {
final MqttUnsubscribe unsubscribe = new MqttUnsubscribe(topicFilters, userProperties);
Expand All @@ -178,12 +178,12 @@ private void encodeUnsubscribe(
}

private void encodeInternal(
final @NotNull byte[] expected, final @NotNull MqttStatefulUnsubscribe unsubscribeInternal) {
final byte @NotNull [] expected, final @NotNull MqttStatefulUnsubscribe unsubscribeInternal) {
encode(unsubscribeInternal, expected);
}

@SuppressWarnings("NullabilityAnnotations")
private class MaximumPacketBuilder {
private static class MaximumPacketBuilder {

private static final String TOPIC = "topic";
private StringBuilder reasonStringBuilder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void addAll_empty_stream_allowed() {

@Test
void addAll_empty_array_allowed() {
final Mqtt5UserProperties properties = Mqtt5UserProperties.builder().addAll(new Mqtt5UserProperty[0]).build();
final Mqtt5UserProperties properties = Mqtt5UserProperties.builder().addAll().build();
assertTrue(properties.asList().isEmpty());
}

Expand Down Expand Up @@ -191,7 +191,8 @@ void addAll_correct_use_and_correct_order_immutable_list() {
}

void compareProperties(
final @NotNull Mqtt5UserProperty[] expected, final @NotNull List<? extends Mqtt5UserProperty> actual) {
final @NotNull Mqtt5UserProperty @NotNull [] expected,
final @NotNull List<? extends Mqtt5UserProperty> actual) {

assertEquals(expected.length, actual.size());

Expand All @@ -204,7 +205,7 @@ void compareProperties(
}

void compareProperties(
final @NotNull Collection<Mqtt5UserProperty> expected,
final @NotNull Collection<@NotNull Mqtt5UserProperty> expected,
final @NotNull List<? extends Mqtt5UserProperty> actual) {
compareProperties(expected.toArray(new Mqtt5UserProperty[0]), actual);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,8 @@ void addSubscriptions_fluent_subscription_and_addSubscription() {
}

void compareSubscriptions(
final @NotNull Mqtt5Subscription[] expected, final @NotNull List<? extends Mqtt5Subscription> actual) {
final @NotNull Mqtt5Subscription @NotNull [] expected,
final @NotNull List<? extends Mqtt5Subscription> actual) {

assertEquals(expected.length, actual.size());

Expand All @@ -399,7 +400,7 @@ void compareSubscriptions(
}

void compareSubscriptions(
final @NotNull Collection<Mqtt5Subscription> expected,
final @NotNull Collection<@NotNull Mqtt5Subscription> expected,
final @NotNull List<? extends Mqtt5Subscription> actual) {

assertEquals(expected.size(), actual.size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,8 @@ void addSubscriptions_fluent_subscription_and_addSubscription() {
}

void compareSubscriptions(
final @NotNull Mqtt3Subscription[] expected, final @NotNull List<? extends Mqtt3Subscription> actual) {
final @NotNull Mqtt3Subscription @NotNull [] expected,
final @NotNull List<? extends Mqtt3Subscription> actual) {

assertEquals(expected.length, actual.size());

Expand All @@ -383,7 +384,7 @@ void compareSubscriptions(
}

void compareSubscriptions(
final @NotNull Collection<Mqtt3Subscription> expected,
final @NotNull Collection<@NotNull Mqtt3Subscription> expected,
final @NotNull List<? extends Mqtt3Subscription> actual) {

assertEquals(expected.size(), actual.size());
Expand Down

0 comments on commit 7cc01bd

Please sign in to comment.