use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectReader in project repseqio by repseqio.
the class VDJCGeneTest method jsonTestNoCurrentLibrary1.
@Test
public void jsonTestNoCurrentLibrary1() throws Exception {
VDJCLibrary library = VDJCLibraryRegistry.getDefaultLibrary("hs");
VDJCGene gene = library.getSafe("TRBV12-3*00");
ObjectWriter writer = GlobalObjectMappers.PRETTY.writerFor(VDJCGene.class);
ObjectReader reader = GlobalObjectMappers.PRETTY.readerFor(VDJCGene.class);
String str = writer.writeValueAsString(gene);
assertTrue(str.endsWith("/TRBV12-3*00\""));
Object geneDeserialized = reader.readValue(str);
assertTrue(geneDeserialized == gene);
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectReader in project cloudbreak by hortonworks.
the class TenantChecker method checkTenant.
public void checkTenant(String tenantId, String accessToken) throws InteractiveLoginException {
if (tenantId == null) {
throw new InteractiveLoginException("Parameter tenantId is required and cannot be null.");
}
Client client = ClientBuilder.newClient();
WebTarget resource = client.target(AZURE_MANAGEMENT);
Builder request = resource.path("/tenants").queryParam("api-version", "2016-06-01").request();
request.accept(MediaType.APPLICATION_JSON);
request.header("Authorization", "Bearer " + accessToken);
Response response = request.get();
if (response.getStatusInfo().getFamily() == Family.SUCCESSFUL) {
String entity = response.readEntity(String.class);
try {
ObjectMapper mapper = new ObjectMapper();
JsonNode tenantArray = mapper.readTree(entity).get("value");
ObjectReader reader = mapper.readerFor(new TypeReference<ArrayList<AzureTenant>>() {
});
List<AzureTenant> tenants = reader.readValue(tenantArray);
for (AzureTenant tenant : tenants) {
if (tenant.getTenantId().equals(tenantId)) {
LOGGER.debug("Tenant definitions successfully retrieved:" + tenant.getTenantId());
return;
}
}
} catch (IOException e) {
throw new InteractiveLoginException(e.toString());
}
throw new InteractiveLoginException("Tenant specified in Profile file not found with id: " + tenantId);
} else {
String errorResponse = response.readEntity(String.class);
try {
String errorMessage = new ObjectMapper().readTree(errorResponse).get("error").get("message").asText();
LOGGER.error("Tenant retrieve error:" + errorMessage);
throw new InteractiveLoginException("Error with the tenant specified in Profile file id: " + tenantId + ", message: " + errorMessage);
} catch (IOException e) {
throw new IllegalStateException(e);
}
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectReader in project onebusaway-application-modules by camsys.
the class CustomJacksonLibHandler method toObject.
public void toObject(Reader in, Object target) throws IOException {
mapper.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false);
ObjectReader or = mapper.readerForUpdating(target);
// , new TypeReference<clazz>);
or.readValue(in);
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectReader in project nzbhydra2 by theotherp.
the class AbstractConfigReplacingTest method replaceConfig.
public void replaceConfig(URL resource) throws IOException {
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.writeValueAsString(baseConfig);
ObjectReader updater = objectMapper.readerForUpdating(baseConfig);
BaseConfig updatedConfig = updater.readValue(resource);
baseConfig.replace(updatedConfig);
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectReader in project logging-log4j2 by apache.
the class LevelMixInTest method testContainer.
@Test
public void testContainer() throws IOException {
final Fixture expected = new Fixture();
final String str = writer.writeValueAsString(expected);
Assert.assertTrue(str.contains("DEBUG"));
final ObjectReader fixtureReader = log4jObjectMapper.readerFor(Fixture.class);
final Fixture actual = fixtureReader.readValue(str);
Assert.assertEquals(expected, actual);
}
Aggregations