Removed usage to IOUtils.toString (#8579)
Specifically the toString reading from inputstream. Signed-off-by: Hilbrand Bouwkamp <hilbrand@h72.nl>
This commit is contained in:
committed by
GitHub
parent
aa3f73d423
commit
1bc55a208b
@@ -16,9 +16,9 @@ import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.openhab.binding.sensibo.internal.dto.AbstractRequest;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
@@ -51,7 +51,8 @@ public class WireHelper {
|
||||
}
|
||||
|
||||
public <T> T deSerializeResponse(final String jsonClasspathName, final Type type) throws IOException {
|
||||
final String json = IOUtils.toString(WireHelper.class.getResourceAsStream(jsonClasspathName));
|
||||
final String json = new String(WireHelper.class.getResourceAsStream(jsonClasspathName).readAllBytes(),
|
||||
StandardCharsets.UTF_8);
|
||||
|
||||
final JsonParser parser = new JsonParser();
|
||||
final JsonObject o = parser.parse(json).getAsJsonObject();
|
||||
@@ -61,7 +62,8 @@ public class WireHelper {
|
||||
}
|
||||
|
||||
public <T> T deSerializeFromClasspathResource(final String jsonClasspathName, final Type type) throws IOException {
|
||||
final String json = IOUtils.toString(WireHelper.class.getResourceAsStream(jsonClasspathName));
|
||||
final String json = new String(WireHelper.class.getResourceAsStream(jsonClasspathName).readAllBytes(),
|
||||
StandardCharsets.UTF_8);
|
||||
return deSerializeFromString(json, type);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,9 +18,9 @@ import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.eclipse.jetty.client.HttpClient;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
@@ -87,12 +87,14 @@ public class SensiboAccountHandlerTest {
|
||||
when(configuration.as(eq(SensiboAccountConfiguration.class))).thenReturn(accountConfig);
|
||||
|
||||
// Setup initial response
|
||||
final String getPodsResponse = IOUtils.toString(getClass().getResourceAsStream(podsResponse));
|
||||
final String getPodsResponse = new String(getClass().getResourceAsStream(podsResponse).readAllBytes(),
|
||||
StandardCharsets.UTF_8);
|
||||
stubFor(get(urlEqualTo("/api/v2/users/me/pods?apiKey=APIKEY"))
|
||||
.willReturn(aResponse().withStatus(200).withBody(getPodsResponse)));
|
||||
|
||||
// Setup 2nd response with details
|
||||
final String getPodDetailsResponse = IOUtils.toString(getClass().getResourceAsStream(podDetailsResponse));
|
||||
final String getPodDetailsResponse = new String(
|
||||
getClass().getResourceAsStream(podDetailsResponse).readAllBytes(), StandardCharsets.UTF_8);
|
||||
stubFor(get(urlEqualTo("/api/v2/pods/PODID?apiKey=APIKEY&fields=*"))
|
||||
.willReturn(aResponse().withStatus(200).withBody(getPodDetailsResponse)));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user