Fixes from modernizer maven plugin in rfc8040 module 85/93285/2
authorVladyslav Marchenko <vladyslav.marchenko@pantheon.tech>
Fri, 23 Oct 2020 10:02:48 +0000 (13:02 +0300)
committerVladyslav Marchenko <vladyslav.marchenko@pantheon.tech>
Fri, 23 Oct 2020 12:38:21 +0000 (15:38 +0300)
Remove some legacy APIs

Change-Id: I689190caf9be2357b2ffb2d2197783ebaba694d9
Signed-off-by: Vladyslav Marchenko <vladyslav.marchenko@pantheon.tech>
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/errors/RestconfDocumentedExceptionMapper.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/JSONRestconfServiceRfc8040Impl.java
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/TestUtils.java
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/CreateStreamUtilTest.java
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/PostDataTransactionUtilTest.java

index a9a640e24c89a43a488ec01b385df07e56246071..b5d713f5ece4dbbfa429e0c705ac93aa0a848a9e 100644 (file)
@@ -14,7 +14,6 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.OutputStreamWriter;
-import java.io.UnsupportedEncodingException;
 import java.nio.charset.StandardCharsets;
 import java.util.Collections;
 import java.util.LinkedHashSet;
@@ -217,11 +216,7 @@ public final class RestconfDocumentedExceptionMapper implements ExceptionMapper<
         } catch (IOException e) {
             throw new IllegalStateException("Cannot write error response body", e);
         }
-        try {
-            return outputStream.toString(StandardCharsets.UTF_8.name());
-        } catch (UnsupportedEncodingException e) {
-            throw new IllegalStateException("Output stream cannot be converted to string representation", e);
-        }
+        return outputStream.toString(StandardCharsets.UTF_8);
     }
 
     /**
index cf6752f5ba75a72e90ee874d11824fd8b1ef5285..3470c593f650953bfe9756ca52873d7894e4d223 100644 (file)
@@ -234,7 +234,7 @@ public final class JSONRestconfServiceRfc8040Impl implements JSONRestconfService
         final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
         writer.writeTo(patchStatusContext, PatchStatusContext.class, null, EMPTY_ANNOTATIONS,
                 MediaType.APPLICATION_JSON_TYPE, null, outputStream);
-        return outputStream.toString(StandardCharsets.UTF_8.name());
+        return outputStream.toString(StandardCharsets.UTF_8);
     }
 
     private static String toJson(final NormalizedNodeContext readData) throws IOException {
@@ -242,7 +242,7 @@ public final class JSONRestconfServiceRfc8040Impl implements JSONRestconfService
         final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
         writer.writeTo(readData, NormalizedNodeContext.class, null, EMPTY_ANNOTATIONS,
                 MediaType.APPLICATION_JSON_TYPE, null, outputStream);
-        return outputStream.toString(StandardCharsets.UTF_8.name());
+        return outputStream.toString(StandardCharsets.UTF_8);
     }
 
     private static boolean isDataMissing(final Exception exception) {
index 86ba28be75addd19314f2871e31b6c81e9d8f8c2..c950aa1166c820dfc12a3646cd9dc12d00a4ea4e 100644 (file)
@@ -189,7 +189,7 @@ public final class TestUtils {
     }
 
     public static String loadTextFile(final String filePath) throws IOException {
-        final FileReader fileReader = new FileReader(filePath);
+        final FileReader fileReader = new FileReader(filePath, StandardCharsets.UTF_8);
         final BufferedReader bufReader = new BufferedReader(fileReader);
 
         String line = null;
index edd27c49c6382eb2c4c12ef1e6735f653f7093ba..dde3ec98f7c448f970d847d7dddb93ba5e492980 100644 (file)
@@ -94,7 +94,7 @@ public class CreateStreamUtilTest {
                 Builders.containerBuilder(rpcInputSchemaNode);
 
         final QName lfQName = QName.create(rpcModule.getQNameModule(), inputOutputName);
-        final DataSchemaNode lfSchemaNode = rpcInputSchemaNode.getDataChildByName(lfQName);
+        final DataSchemaNode lfSchemaNode = rpcInputSchemaNode.findDataChildByName(lfQName).orElseThrow();
 
         assertTrue(lfSchemaNode instanceof LeafSchemaNode);
 
index 0e251c8124dfefe088bc97eb945eaee5e57f8ec8..6a96617ee9f49a0a1cf07ed03803d91b683eb033 100644 (file)
@@ -21,6 +21,7 @@ import static org.opendaylight.yangtools.util.concurrent.FluentFutures.immediate
 
 import java.io.UnsupportedEncodingException;
 import java.net.URLDecoder;
+import java.nio.charset.StandardCharsets;
 import java.util.Collection;
 import java.util.Optional;
 import javax.ws.rs.core.Response;
@@ -195,7 +196,7 @@ public class PostDataTransactionUtilTest {
         Response response = PostDataTransactionUtil.postData(this.uriInfo, payload,
                         new MdsalRestconfStrategy(transactionChainHandler), this.schema, null, null);
         assertEquals(201, response.getStatus());
-        assertThat(URLDecoder.decode(response.getLocation().toString(), "UTF-8"),
+        assertThat(URLDecoder.decode(response.getLocation().toString(), StandardCharsets.UTF_8),
             containsString(identifier.getValue(identifier.keySet().iterator().next()).toString()));
         verify(this.readWrite).exists(LogicalDatastoreType.CONFIGURATION, node);
         verify(this.readWrite).put(LogicalDatastoreType.CONFIGURATION, node, data.getValue().iterator().next());
@@ -203,7 +204,7 @@ public class PostDataTransactionUtilTest {
         response = PostDataTransactionUtil.postData(this.uriInfo, payload,
                 new NetconfRestconfStrategy(netconfService), this.schema, null, null);
         assertEquals(201, response.getStatus());
-        assertThat(URLDecoder.decode(response.getLocation().toString(), "UTF-8"),
+        assertThat(URLDecoder.decode(response.getLocation().toString(), StandardCharsets.UTF_8),
                 containsString(identifier.getValue(identifier.keySet().iterator().next()).toString()));
         verify(this.netconfService).getConfig(node);
         verify(this.netconfService).create(LogicalDatastoreType.CONFIGURATION, node, data.getValue().iterator().next(),