use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonFactory in project dropwizard by dropwizard.
the class JacksonTest method objectMapperUsesGivenCustomJsonFactory.
@Test
void objectMapperUsesGivenCustomJsonFactory() {
JsonFactory factory = Mockito.mock(JsonFactory.class);
ObjectMapper mapper = Jackson.newObjectMapper(factory);
assertThat(mapper.getFactory()).isSameAs(factory);
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonFactory in project pinpoint by naver.
the class ObjectMapperJDK7IT method testConstructor.
@Test
public void testConstructor() throws Exception {
ObjectMapper mapper1 = new ObjectMapper();
ObjectMapper mapper2 = new ObjectMapper(new JsonFactory());
PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
verifier.printCache();
Constructor<?> omConstructor = ObjectMapper.class.getConstructor(JsonFactory.class, DefaultSerializerProvider.class, DefaultDeserializationContext.class);
Constructor<?> omConstructor1 = ObjectMapper.class.getConstructor();
Constructor<?> omConstructor2 = ObjectMapper.class.getConstructor(JsonFactory.class);
verifier.verifyTrace(event(SERVICE_TYPE, omConstructor));
verifier.verifyTrace(event(SERVICE_TYPE, omConstructor1));
verifier.verifyTrace(event(SERVICE_TYPE, omConstructor));
verifier.verifyTrace(event(SERVICE_TYPE, omConstructor2));
verifier.verifyTraceCount(0);
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonFactory in project pinpoint by naver.
the class ObjectMapperIT method testConstructor.
@Test
public void testConstructor() throws Exception {
ObjectMapper mapper1 = new ObjectMapper();
ObjectMapper mapper2 = new ObjectMapper(new JsonFactory());
PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
verifier.printCache();
Constructor<?> omConstructor = ObjectMapper.class.getConstructor(JsonFactory.class, DefaultSerializerProvider.class, DefaultDeserializationContext.class);
Constructor<?> omConstructor1 = ObjectMapper.class.getConstructor();
Constructor<?> omConstructor2 = ObjectMapper.class.getConstructor(JsonFactory.class);
verifier.verifyTrace(event(SERVICE_TYPE, omConstructor));
verifier.verifyTrace(event(SERVICE_TYPE, omConstructor1));
verifier.verifyTrace(event(SERVICE_TYPE, omConstructor));
verifier.verifyTrace(event(SERVICE_TYPE, omConstructor2));
verifier.verifyTraceCount(0);
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonFactory in project pinpoint by naver.
the class AgentTimeHistogramTest method testViewModel.
@Test
public void testViewModel() throws IOException {
Application app = new Application("test", ServiceType.STAND_ALONE);
AgentTimeHistogramBuilder builder = new AgentTimeHistogramBuilder(app, Range.newRange(0, 1000 * 60));
List<ResponseTime> responseHistogramList = createResponseTime(app, "test1", "test2");
AgentTimeHistogram histogram = builder.build(responseHistogramList);
List<AgentResponseTimeViewModel> viewModel = histogram.createViewModel(TimeHistogramFormat.V1);
logger.debug("{}", viewModel);
JsonFactory jsonFactory = mapper.getFactory();
StringWriter stringWriter = new StringWriter();
JsonGenerator jsonGenerator = jsonFactory.createGenerator(stringWriter);
jsonGenerator.writeStartObject();
for (AgentResponseTimeViewModel agentResponseTimeViewModel : viewModel) {
jsonGenerator.writeObject(agentResponseTimeViewModel);
}
jsonGenerator.writeEndObject();
jsonGenerator.flush();
jsonGenerator.close();
logger.debug(stringWriter.toString());
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonFactory in project pyramid by cheng-li.
the class VisualizerOld method getPositions.
private List<Integer> getPositions(Object docId, Object field, Object keywords, Object slop, Object in_order) throws IOException {
System.out.println(docId + " " + field + " " + keywords + " " + slop + " " + in_order);
final URL url = new URL("http://localhost:9200/ohsumed_20000/document/_search");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setDoOutput(true);
conn.addRequestProperty("Content-Type", "application/" + "POST");
final String clauses = getJsonString(newSpanTerm((String) keywords, (String) field));
final String body = "{\"explain\":\"false\"," + " \"query\":{" + " \"filtered\":{" + " \"query\":{" + " \"span_near\": {" + " \"clauses\":" + clauses + "," + " \"slop\":" + slop.toString() + "," + " \"in_order\":" + in_order.toString() + "," + " \"collect_payloads\": false}}," + " \"filter\":{\"ids\":{\"values\":[\"" + docId + "\"]}}}}," + " \"highlight\":{\"fields\":{\"" + field + "\":{}}}," + " \"size\":1}";
System.out.println(body);
conn.setRequestProperty("Content-Length", Integer.toString(body.length()));
conn.getOutputStream().write(body.getBytes("UTF-8"));
final BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
final StringBuilder result = new StringBuilder();
for (String line = null; (line = reader.readLine()) != null; ) {
result.append(line);
}
final JsonFactory factory = new JsonFactory();
final ObjectMapper mapper = new ObjectMapper(factory);
final Map<String, Object> hits = mapper.readValue(result.toString(), new TypeReference<Map<String, Object>>() {
});
final List<Integer> positions = new ArrayList<>();
if (hits.get("hits") != null && ((Map<String, Object>) hits.get("hits")).containsKey("hits")) {
for (String hlField : ((Map<String, Object>) ((Map<String, Object>) ((List<Map<String, Object>>) ((Map<String, Object>) hits.get("hits")).get("hits")).get(0)).get("highlight")).keySet()) {
final String text = (String) ((Map<String, Object>) (((List<Map<String, Object>>) ((Map<String, Object>) hits.get("hits")).get("hits")).get(0).get("_source"))).get(hlField);
final List<String> highlights = (List<String>) ((Map<String, Object>) (((List<Map<String, Object>>) ((Map<String, Object>) hits.get("hits")).get("hits")).get(0).get("highlight"))).get(hlField);
for (String HL : highlights) {
String cleanHL = HL.replaceAll("<em>", "");
cleanHL = cleanHL.replaceAll("</em>", "");
int baseindex = text.indexOf(cleanHL);
// in case the highlight not found in body
if (baseindex == -1) {
continue;
}
while (HL.indexOf("<em>") != -1) {
int start = HL.indexOf("<em>") + baseindex;
HL = HL.replace("<em>", "");
int end = HL.indexOf("</em>") + baseindex;
HL = HL.replace("</em>", "");
positions.add(start);
positions.add(end);
}
}
}
}
return positions;
}
Aggregations