From eb79ec73f01d31853e411843f64172ee1c5703d0 Mon Sep 17 00:00:00 2001 From: Vladislav Bauer Date: Sat, 15 Aug 2015 03:05:42 +0600 Subject: [PATCH] Add unit tests for constructors from util classes --- .../java/com/google/gson/internal/$Gson$Preconditions.java | 4 ++++ gson/src/main/java/com/google/gson/internal/$Gson$Types.java | 4 +++- gson/src/main/java/com/google/gson/internal/Primitives.java | 4 +++- gson/src/main/java/com/google/gson/internal/Streams.java | 4 ++++ .../main/java/com/google/gson/internal/bind/TypeAdapters.java | 4 +++- gson/src/test/java/com/google/gson/common/MoreAsserts.java | 1 + 6 files changed, 18 insertions(+), 3 deletions(-) diff --git a/gson/src/main/java/com/google/gson/internal/$Gson$Preconditions.java b/gson/src/main/java/com/google/gson/internal/$Gson$Preconditions.java index ccc0390d..f0e7d3fa 100644 --- a/gson/src/main/java/com/google/gson/internal/$Gson$Preconditions.java +++ b/gson/src/main/java/com/google/gson/internal/$Gson$Preconditions.java @@ -30,6 +30,10 @@ package com.google.gson.internal; * @author Joel Leitch */ public final class $Gson$Preconditions { + private $Gson$Preconditions() { + throw new UnsupportedOperationException(); + } + public static T checkNotNull(T obj) { if (obj == null) { throw new NullPointerException(); diff --git a/gson/src/main/java/com/google/gson/internal/$Gson$Types.java b/gson/src/main/java/com/google/gson/internal/$Gson$Types.java index 9365be74..745d0719 100644 --- a/gson/src/main/java/com/google/gson/internal/$Gson$Types.java +++ b/gson/src/main/java/com/google/gson/internal/$Gson$Types.java @@ -43,7 +43,9 @@ import java.util.Properties; public final class $Gson$Types { static final Type[] EMPTY_TYPE_ARRAY = new Type[] {}; - private $Gson$Types() {} + private $Gson$Types() { + throw new UnsupportedOperationException(); + } /** * Returns a new parameterized type, applying {@code typeArguments} to diff --git a/gson/src/main/java/com/google/gson/internal/Primitives.java b/gson/src/main/java/com/google/gson/internal/Primitives.java index b797139b..a98f6242 100644 --- a/gson/src/main/java/com/google/gson/internal/Primitives.java +++ b/gson/src/main/java/com/google/gson/internal/Primitives.java @@ -29,7 +29,9 @@ import java.util.Map; * @author Kevin Bourrillion */ public final class Primitives { - private Primitives() {} + private Primitives() { + throw new UnsupportedOperationException(); + } /** A map from primitive types to their corresponding wrapper types. */ private static final Map, Class> PRIMITIVE_TO_WRAPPER_TYPE; diff --git a/gson/src/main/java/com/google/gson/internal/Streams.java b/gson/src/main/java/com/google/gson/internal/Streams.java index 9c29f2a4..7f00f11d 100644 --- a/gson/src/main/java/com/google/gson/internal/Streams.java +++ b/gson/src/main/java/com/google/gson/internal/Streams.java @@ -33,6 +33,10 @@ import java.io.Writer; * Reads and writes GSON parse trees over streams. */ public final class Streams { + private Streams() { + throw new UnsupportedOperationException(); + } + /** * Takes a reader in any state and returns the next value as a JsonElement. */ diff --git a/gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java b/gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java index 87f8c05e..a8465fcb 100644 --- a/gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java +++ b/gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java @@ -55,7 +55,9 @@ import com.google.gson.stream.JsonWriter; * Type adapters for basic types. */ public final class TypeAdapters { - private TypeAdapters() {} + private TypeAdapters() { + throw new UnsupportedOperationException(); + } @SuppressWarnings("rawtypes") public static final TypeAdapter CLASS = new TypeAdapter() { diff --git a/gson/src/test/java/com/google/gson/common/MoreAsserts.java b/gson/src/test/java/com/google/gson/common/MoreAsserts.java index 93e32dec..5e05832a 100644 --- a/gson/src/test/java/com/google/gson/common/MoreAsserts.java +++ b/gson/src/test/java/com/google/gson/common/MoreAsserts.java @@ -69,4 +69,5 @@ public class MoreAsserts { Assert.assertFalse(a.equals(null)); Assert.assertFalse(a.equals(new Object())); } + }