Search in sources :

Example 71 with ObjectReader

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectReader in project azure-tools-for-java by Microsoft.

the class AzureSdkLibraryService method loadSpringSDKEntities.

public static List<AzureSdkServiceEntity> loadSpringSDKEntities(final URL destination) {
    try {
        final ObjectReader reader = YML_MAPPER.readerFor(AzureSdkServiceEntity.class);
        final MappingIterator<AzureSdkServiceEntity> data = reader.readValues(destination);
        return data.readAll();
    } catch (final IOException e) {
        log.warn(String.format("failed to load Azure SDK list from \"%s\"", destination.toString()), e);
    }
    return Collections.emptyList();
}
Also used : AzureSdkServiceEntity(com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureSdkServiceEntity) ObjectReader(com.fasterxml.jackson.databind.ObjectReader) IOException(java.io.IOException)

Example 72 with ObjectReader

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectReader in project azure-tools-for-java by Microsoft.

the class AzureSdkLibraryService method loadAzureSDKWhitelist.

@Cacheable("sdk/packages/whitelist")
@AzureOperation(name = "sdk.load_meta_data.whitelist", type = AzureOperation.Type.TASK)
private static Set<String> loadAzureSDKWhitelist() {
    try {
        final URL destination = AzureSdkLibraryService.class.getResource(SDK_ALLOW_LIST_CSV);
        final ObjectReader reader = CSV_MAPPER.readerFor(AzureSdkAllowListEntity.class).with(CsvSchema.emptySchema().withHeader());
        final MappingIterator<AzureSdkAllowListEntity> data = reader.readValues(destination);
        return data.readAll().stream().filter(e -> StringUtils.isNoneBlank(e.getArtifactId(), e.getGroupId())).map(AzureSdkAllowListEntity::getPackageName).collect(Collectors.toSet());
    } catch (final IOException e) {
        log.warn(String.format("failed to load Azure SDK allow list from \"%s\"", SDK_ALLOW_LIST_CSV), e);
    }
    return Collections.emptySet();
}
Also used : ObjectReader(com.fasterxml.jackson.databind.ObjectReader) IOException(java.io.IOException) AzureSdkAllowListEntity(com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureSdkAllowListEntity) URL(java.net.URL) Cacheable(com.microsoft.azure.toolkit.lib.common.cache.Cacheable) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)

Example 73 with ObjectReader

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectReader in project azure-tools-for-java by Microsoft.

the class AzureSdkLibraryService method loadAzureSDKEntities.

public static List<AzureJavaSdkEntity> loadAzureSDKEntities(final URL destination) {
    try {
        final ObjectReader reader = CSV_MAPPER.readerFor(AzureJavaSdkEntity.class).with(CsvSchema.emptySchema().withHeader());
        final MappingIterator<AzureJavaSdkEntity> data = reader.readValues(destination);
        return data.readAll().stream().filter(e -> StringUtils.isNoneBlank(e.getArtifactId(), e.getGroupId())).collect(Collectors.toList());
    } catch (final IOException e) {
        log.warn(String.format("failed to load Azure SDK list from \"%s\"", destination.toString()), e);
    }
    return Collections.emptyList();
}
Also used : java.util(java.util) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation) SneakyThrows(lombok.SneakyThrows) URL(java.net.URL) MappingIterator(com.fasterxml.jackson.databind.MappingIterator) StringUtils(org.apache.commons.lang3.StringUtils) Function(java.util.function.Function) DeserializationFeature(com.fasterxml.jackson.databind.DeserializationFeature) CollectionUtils(org.apache.commons.collections4.CollectionUtils) ObjectReader(com.fasterxml.jackson.databind.ObjectReader) AzureSdkAllowListEntity(com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureSdkAllowListEntity) CacheEvict(com.microsoft.azure.toolkit.lib.common.cache.CacheEvict) YAMLMapper(com.fasterxml.jackson.dataformat.yaml.YAMLMapper) CacheManager(com.microsoft.azure.toolkit.lib.common.cache.CacheManager) Cacheable(com.microsoft.azure.toolkit.lib.common.cache.Cacheable) Preload(com.microsoft.azure.toolkit.lib.common.cache.Preload) Nonnull(javax.annotation.Nonnull) AzureSdkArtifactEntity(com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureSdkArtifactEntity) AzureToolkitRuntimeException(com.microsoft.azure.toolkit.lib.common.exception.AzureToolkitRuntimeException) ImmutableMap(com.google.common.collect.ImmutableMap) MalformedURLException(java.net.MalformedURLException) CsvMapper(com.fasterxml.jackson.dataformat.csv.CsvMapper) AzureJavaSdkEntity(com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureJavaSdkEntity) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) CsvSchema(com.fasterxml.jackson.dataformat.csv.CsvSchema) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) ExecutionException(java.util.concurrent.ExecutionException) Slf4j(lombok.extern.slf4j.Slf4j) AzureSdkFeatureEntity(com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureSdkFeatureEntity) AzureSdkServiceEntity(com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureSdkServiceEntity) AzureJavaSdkEntity(com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureJavaSdkEntity) ObjectReader(com.fasterxml.jackson.databind.ObjectReader) IOException(java.io.IOException)

Example 74 with ObjectReader

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectReader in project pinpoint by naver.

the class ObjectMapperIT method testReadValue.

@Test
public void testReadValue() throws Exception {
    String json_str = "{\"name\" : \"Jackson\"}";
    byte[] json_b = json_str.getBytes(UTF_8);
    mapper.readValue(json_str, __POJO.class);
    mapper.readValue(json_b, __POJO.class);
    ObjectReader reader = mapper.reader(__POJO.class);
    reader.readValue(json_str);
    reader.readValue(json_b);
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    verifier.printCache();
    Method mapperReadValueString = ObjectMapper.class.getMethod("readValue", String.class, Class.class);
    Method mapperReadValueBytes = ObjectMapper.class.getMethod("readValue", byte[].class, Class.class);
    Method readerReadValueString = ObjectReader.class.getMethod("readValue", String.class);
    Method readerReadValueBytes = ObjectReader.class.getMethod("readValue", byte[].class);
    verifier.verifyTrace(event(SERVICE_TYPE, mapperReadValueString, annotation(ANNOTATION_KEY, json_str.length())));
    verifier.verifyTrace(event(SERVICE_TYPE, mapperReadValueBytes, annotation(ANNOTATION_KEY, json_b.length)));
    verifier.verifyTrace(event(SERVICE_TYPE, readerReadValueString, annotation(ANNOTATION_KEY, json_str.length())));
    verifier.verifyTrace(event(SERVICE_TYPE, readerReadValueBytes, annotation(ANNOTATION_KEY, json_b.length)));
    verifier.verifyTraceCount(0);
}
Also used : ObjectReader(com.fasterxml.jackson.databind.ObjectReader) Method(java.lang.reflect.Method) PluginTestVerifier(com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier) Test(org.junit.Test)

Example 75 with ObjectReader

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectReader in project pinpoint by naver.

the class ObjectReaderJDK7IT method testReadValue.

@Test
public void testReadValue() throws Exception {
    String json_str = "{\"name\" : \"Jackson\"}";
    byte[] json_b = json_str.getBytes(UTF_8);
    @SuppressWarnings("deprecation") ObjectReader reader = mapper.reader(__POJO.class);
    __POJO pojo = reader.readValue(json_str);
    pojo = reader.readValue(json_b);
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    verifier.printCache();
    Method readval1 = ObjectReader.class.getMethod("readValue", String.class);
    Method readval2 = ObjectReader.class.getMethod("readValue", byte[].class);
    verifier.verifyTrace(event("JACKSON", readval1, Expectations.annotation("jackson.json.length", json_str.length())));
    verifier.verifyTrace(event("JACKSON", readval2, Expectations.annotation("jackson.json.length", json_b.length)));
    verifier.verifyTraceCount(0);
}
Also used : ObjectReader(com.fasterxml.jackson.databind.ObjectReader) Method(java.lang.reflect.Method) PluginTestVerifier(com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier) Test(org.junit.Test)

Aggregations

ObjectReader (com.fasterxml.jackson.databind.ObjectReader)82 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)33 IOException (java.io.IOException)32 Test (org.junit.Test)23 ObjectWriter (com.fasterxml.jackson.databind.ObjectWriter)12 JsonNode (com.fasterxml.jackson.databind.JsonNode)9 ArrayList (java.util.ArrayList)8 JavaType (com.fasterxml.jackson.databind.JavaType)7 InputStream (java.io.InputStream)7 HashMap (java.util.HashMap)6 CsvSchema (com.fasterxml.jackson.dataformat.csv.CsvSchema)5 Map (java.util.Map)5 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)4 CsvMapper (com.fasterxml.jackson.dataformat.csv.CsvMapper)4 PluginTestVerifier (com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier)4 Method (java.lang.reflect.Method)4 List (java.util.List)4 DeserializationFeature (com.fasterxml.jackson.databind.DeserializationFeature)3 MappingIterator (com.fasterxml.jackson.databind.MappingIterator)3 JSONLayoutPage (org.knime.js.core.layout.bs.JSONLayoutPage)3