use of com.fasterxml.jackson.core.type.TypeReference in project nem2-sdk-java by nemtech.
the class TransactionHttp method getTransactionStatuses.
@Override
public Observable<List<TransactionStatus>> getTransactionStatuses(List<String> transactionHashes) {
JsonObject requestBody = new JsonObject();
requestBody.put("hashes", transactionHashes);
return this.client.postAbs(this.url + "/statuses").as(BodyCodec.jsonArray()).rxSendJson(requestBody).toObservable().map(HttpResponse::body).map(json -> objectMapper.<List<TransactionStatusDTO>>readValue(json.toString(), new TypeReference<List<TransactionStatusDTO>>() {
})).flatMapIterable(item -> item).map(transactionStatusDTO -> new TransactionStatus(transactionStatusDTO.getGroup(), transactionStatusDTO.getStatus(), transactionStatusDTO.getHash(), new Deadline(transactionStatusDTO.getDeadline().extractIntArray()), transactionStatusDTO.getHeight().extractIntArray())).toList().toObservable();
}
use of com.fasterxml.jackson.core.type.TypeReference in project CzechIdMng by bcvsolutions.
the class IdentityReportExecutorIntegrationTest method testDisabledIdentity.
@Test
@Transactional
public void testDisabledIdentity() throws IOException {
// prepare test identities
IdmIdentityDto identityOne = helper.createIdentity();
IdmIdentityDto identityDisabled = helper.createIdentity();
identityService.disable(identityDisabled.getId());
//
// prepare report filter
RptReportDto report = new RptReportDto(UUID.randomUUID());
report.setExecutorName(reportExecutor.getName());
IdmFormDto filter = new IdmFormDto();
IdmFormDefinitionDto definition = reportExecutor.getFormDefinition();
IdmFormValueDto disabled = new IdmFormValueDto(definition.getMappedAttributeByCode(IdmIdentityFilter.PARAMETER_DISABLED));
disabled.setValue(false);
filter.getValues().add(disabled);
filter.setFormDefinition(definition.getId());
report.setFilter(filter);
//
// generate report
report = reportExecutor.generate(report);
Assert.assertNotNull(report.getData());
List<IdmIdentityDto> identityRoles = mapper.readValue(attachmentManager.getAttachmentData(report.getData()), new TypeReference<List<IdmIdentityDto>>() {
});
//
// test
Assert.assertTrue(identityRoles.stream().anyMatch(i -> i.equals(identityOne)));
Assert.assertFalse(identityRoles.stream().anyMatch(i -> i.equals(identityDisabled)));
//
attachmentManager.deleteAttachments(report);
}
use of com.fasterxml.jackson.core.type.TypeReference in project CzechIdMng by bcvsolutions.
the class IdentityReportExecutorIntegrationTest method testDisabledIdentity.
@Test
@Transactional
public void testDisabledIdentity() throws IOException {
// prepare test identities
IdmIdentityDto identityOne = helper.createIdentity();
IdmIdentityDto identityDisabled = helper.createIdentity();
identityService.disable(identityDisabled.getId());
//
// prepare report filter
RptReportDto report = new RptReportDto(UUID.randomUUID());
report.setExecutorName(reportExecutor.getName());
IdmFormDto filter = new IdmFormDto();
IdmFormDefinitionDto definition = reportExecutor.getFormDefinition();
IdmFormValueDto disabled = new IdmFormValueDto(definition.getMappedAttributeByCode(IdmIdentityFilter.PARAMETER_DISABLED));
disabled.setValue(false);
filter.getValues().add(disabled);
filter.setFormDefinition(definition.getId());
report.setFilter(filter);
//
// generate report
report = reportExecutor.generate(report);
Assert.assertNotNull(report.getData());
List<IdmIdentityDto> identityRoles = mapper.readValue(attachmentManager.getAttachmentData(report.getData()), new TypeReference<List<IdmIdentityDto>>() {
});
//
// test
Assert.assertTrue(identityRoles.stream().anyMatch(i -> i.equals(identityOne)));
Assert.assertFalse(identityRoles.stream().anyMatch(i -> i.equals(identityDisabled)));
//
attachmentManager.deleteAttachments(report);
}
use of com.fasterxml.jackson.core.type.TypeReference in project cas by apereo.
the class JsonResourceInterruptInquirer method readResourceForInterrupts.
@SneakyThrows
private void readResourceForInterrupts() {
this.interrupts = new LinkedHashMap<>();
if (ResourceUtils.doesResourceExist(resource)) {
try (Reader reader = new InputStreamReader(resource.getInputStream(), StandardCharsets.UTF_8)) {
final TypeReference<Map<String, InterruptResponse>> personList = new TypeReference<Map<String, InterruptResponse>>() {
};
this.interrupts = MAPPER.readValue(JsonValue.readHjson(reader).toString(), personList);
}
}
}
use of com.fasterxml.jackson.core.type.TypeReference in project grakn by graknlabs.
the class StorageConfig method parseStringToMap.
private static Map<String, Object> parseStringToMap(String yaml) {
ObjectMapper mapper = new ObjectMapper(new YAMLFactory().enable(YAMLGenerator.Feature.MINIMIZE_QUOTES));
try {
TypeReference<Map<String, Object>> reference = new TypeReference<Map<String, Object>>() {
};
Map<String, Object> yamlParams = mapper.readValue(yaml, reference);
return Maps.transformValues(yamlParams, value -> value == null ? EMPTY_VALUE : value);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
Aggregations