org.codehaus.jackson.JsonGenerationException Java Examples
The following examples show how to use
org.codehaus.jackson.JsonGenerationException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JSONRPCEncoder.java From bitcoin-transaction-explorer with MIT License | 6 votes |
/** * TODO If we could get the nasty pre-serialization stuff into the serialization policy, that'd be great. */ public static String getRequestString(final String method, final Object... parameters) throws JsonGenerationException, JsonMappingException, IOException { final ArrayList<Object> parameterLst = new ArrayList<>(); for (Object parameter : parameters) { // Just check if this parameter is a number, if it is, make it an explicit // number if (parameter instanceof String) { if (((String) parameter).toLowerCase().equals("true")) { parameter = true; } else if (((String) parameter).toLowerCase().equals("false")) { parameter = false; } else if (parameter instanceof String) { try { parameter = Integer.parseInt((String) parameter); } catch (final NumberFormatException e) { // eat } } } parameterLst.add(parameter); } return getRequestStringWithParameters(method, parameterLst); }
Example #2
Source File: StatusUpdateResource.java From helix with Apache License 2.0 | 6 votes |
StringRepresentation getInstanceStatusUpdateRepresentation(String clusterName, String instanceName, String resourceGroup) throws JsonGenerationException, JsonMappingException, IOException { ZkClient zkClient = (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT); String instanceSessionId = ClusterRepresentationUtil.getInstanceSessionId(zkClient, clusterName, instanceName); Builder keyBuilder = new PropertyKey.Builder(clusterName); String message = ClusterRepresentationUtil.getInstancePropertiesAsString(zkClient, clusterName, keyBuilder.stateTransitionStatus(instanceName, instanceSessionId, resourceGroup), // instanceSessionId // + "__" // + resourceGroup, MediaType.APPLICATION_JSON); StringRepresentation representation = new StringRepresentation(message, MediaType.APPLICATION_JSON); return representation; }
Example #3
Source File: EPLUtils.java From jetstream-esper with GNU General Public License v2.0 | 6 votes |
public static String toJsonString(Object obj, boolean bStripJsReservedWords) throws JsonGenerationException, JsonMappingException, IOException { String strResult = null; if (obj != null) { if (bStripJsReservedWords && obj instanceof JetstreamEvent) obj = ((JetstreamEvent)obj).getFilteredEvent(); try { ObjectMapper mapper = new ObjectMapper(); Writer writer = new StringWriter(); mapper.writeValue(writer, obj); strResult = writer.toString(); } catch (Throwable t) { if (m_nErrorCount++ % 10000 == 0 && LOGGER.isErrorEnabled()) LOGGER.error( "", t); } } return strResult; }
Example #4
Source File: MockController.java From helix with Apache License 2.0 | 6 votes |
void sendMessage(String msgId, String instanceName, String fromState, String toState, String partitionKey, int partitionId) throws InterruptedException, JsonGenerationException, JsonMappingException, IOException { Message message = new Message(MessageType.STATE_TRANSITION, msgId); message.setMsgId(msgId); message.setSrcName(srcName); message.setTgtName(instanceName); message.setMsgState(MessageState.NEW); message.setFromState(fromState); message.setToState(toState); // message.setPartitionId(partitionId); message.setPartitionName(partitionKey); String path = PropertyPathBuilder.instanceMessage(clusterName, instanceName, message.getId()); ObjectMapper mapper = new ObjectMapper(); StringWriter sw = new StringWriter(); mapper.writeValueUsingView(sw, message, Message.class); System.out.println(sw.toString()); client.delete(path); Thread.sleep(10000); ZNRecord record = client.readData(PropertyPathBuilder.liveInstance(clusterName, instanceName)); message.setTgtSessionId(record.getSimpleField(LiveInstanceProperty.SESSION_ID.toString()) .toString()); client.createPersistent(path, message); }
Example #5
Source File: InstanceResource.java From helix with Apache License 2.0 | 6 votes |
StringRepresentation getInstanceRepresentation() throws JsonGenerationException, JsonMappingException, IOException { String clusterName = ResourceUtil.getAttributeFromRequest(getRequest(), ResourceUtil.RequestKey.CLUSTER_NAME); String instanceName = ResourceUtil.getAttributeFromRequest(getRequest(), ResourceUtil.RequestKey.INSTANCE_NAME); Builder keyBuilder = new PropertyKey.Builder(clusterName); ZkClient zkclient = ResourceUtil.getAttributeFromCtx(getContext(), ResourceUtil.ContextKey.RAW_ZKCLIENT); String instanceCfgStr = ResourceUtil.readZkAsBytes(zkclient, keyBuilder.instanceConfig(instanceName)); StringRepresentation representation = new StringRepresentation(instanceCfgStr, MediaType.APPLICATION_JSON); return representation; }
Example #6
Source File: Simulator.java From realtime-analytics with GNU General Public License v2.0 | 6 votes |
private static void sendMessage() throws IOException, JsonProcessingException, JsonGenerationException, JsonMappingException, UnsupportedEncodingException, HttpException { ObjectMapper mapper = new ObjectMapper(); Map<String, Object> m = new HashMap<String, Object>(); m.put("si", "12345"); m.put("ct", System.currentTimeMillis()); String payload = mapper.writeValueAsString(m); HttpClient client = new HttpClient(); PostMethod method = new PostMethod("http://localhost:8080/tracking/ingest/PulsarRawEvent"); // method.addRequestHeader("Accept-Encoding", "gzip,deflate,sdch"); method.setRequestEntity(new StringRequestEntity(payload, "application/json", "UTF-8")); int status = client.executeMethod(method); System.out.println(Arrays.toString(method.getResponseHeaders())); System.out.println("Status code: " + status + ", Body: " + method.getResponseBodyAsString()); }
Example #7
Source File: OpenApiService.java From SI with BSD 2-Clause "Simplified" License | 6 votes |
public HashMap<String, Object> execute(String operation, String content) throws JsonGenerationException, JsonMappingException, IOException, UserSysException { HashMap<String, Object> res = callOpenAPI(operation, content); //try { //int status = (Integer)res.get("status"); String body = (String)res.get("body"); ObjectMapper mapper = new ObjectMapper(); Object json = mapper.readValue(body, Object.class); res.put("json", json); //} catch (JsonGenerationException ex) { // res.put("exception", ex); //} catch (JsonMappingException ex) { // res.put("exception", ex); //} catch (IOException ex) { // res.put("exception", ex); //} catch (UserSysException ex) { //} return res; }
Example #8
Source File: CurrentStateResource.java From helix with Apache License 2.0 | 6 votes |
StringRepresentation getInstanceCurrentStateRepresentation(String clusterName, String instanceName, String resourceGroup) throws JsonGenerationException, JsonMappingException, IOException { ZkClient zkClient = (ZkClient) getRequest().getAttributes().get(RestAdminApplication.ZKCLIENT); String instanceSessionId = ClusterRepresentationUtil.getInstanceSessionId(zkClient, clusterName, instanceName); Builder keyBuilder = new PropertyKey.Builder(clusterName); String message = ClusterRepresentationUtil.getInstancePropertyAsString(zkClient, clusterName, keyBuilder.currentState(instanceName, instanceSessionId, resourceGroup), MediaType.APPLICATION_JSON); StringRepresentation representation = new StringRepresentation(message, MediaType.APPLICATION_JSON); return representation; }
Example #9
Source File: OpenApiService.java From SI with BSD 2-Clause "Simplified" License | 6 votes |
public HashMap<String, Object> execute(String operation, String content) throws JsonGenerationException, JsonMappingException, IOException, UserSysException { HashMap<String, Object> res = callOpenAPI(operation, content); //try { //int status = (Integer)res.get("status"); String body = (String)res.get("body"); ObjectMapper mapper = new ObjectMapper(); Object json = mapper.readValue(body, Object.class); res.put("json", json); //} catch (JsonGenerationException ex) { // res.put("exception", ex); //} catch (JsonMappingException ex) { // res.put("exception", ex); //} catch (IOException ex) { // res.put("exception", ex); //} catch (UserSysException ex) { //} return res; }
Example #10
Source File: SchedulerTasksResource.java From helix with Apache License 2.0 | 6 votes |
StringRepresentation getSchedulerTasksRepresentation() throws JsonGenerationException, JsonMappingException, IOException { String clusterName = (String) getRequest().getAttributes().get("clusterName"); String instanceName = (String) getRequest().getAttributes().get("instanceName"); ZkClient zkClient = (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT); ClusterSetup setupTool = new ClusterSetup(zkClient); List<String> instances = setupTool.getClusterManagementTool().getInstancesInCluster(clusterName); HelixDataAccessor accessor = ClusterRepresentationUtil.getClusterDataAccessor(zkClient, clusterName); LiveInstance liveInstance = accessor.getProperty(accessor.keyBuilder().liveInstance(instanceName)); String sessionId = liveInstance.getEphemeralOwner(); StringRepresentation representation = new StringRepresentation("");// (ClusterRepresentationUtil.ObjectToJson(instanceConfigs), // MediaType.APPLICATION_JSON); return representation; }
Example #11
Source File: TestOLAPCubeCountDistinct.java From Cubert with Apache License 2.0 | 6 votes |
@Test void testThreeDimsTeamGroupingSets() throws JsonGenerationException, JsonMappingException, IOException, InterruptedException { // members: srinivas, maneesh, krishna, saurabh, rui // dimensions: country code, number of monitors, vegetarian Object[][] rows = { { 1, (int) 1, (int) 2, (int) 1 }, { 2, (int) 1, (int) 2, (int) 2 }, { 3, (int) 1, (int) 1, (int) 1 }, { 4, (int) 1, (int) 1, (int) 2 }, { 5, (int) 2, (int) 2, (int) 2 } }; String[] expected = new String[] { "(1,,,4)", "(2,,,1)", "(1,1,,2)", "(1,2,,2)", "(2,2,,1)" }; validateGroupingSets(rows, expected, new String[] { "Dim0,Dim1", "Dim0" }); }
Example #12
Source File: ErrorsResource.java From helix with Apache License 2.0 | 6 votes |
StringRepresentation getInstanceErrorsRepresentation(String clusterName, String instanceName) throws JsonGenerationException, JsonMappingException, IOException { ZkClient zkClient = (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT); ; String instanceSessionId = ClusterRepresentationUtil.getInstanceSessionId(zkClient, clusterName, instanceName); String message = ClusterRepresentationUtil .getInstancePropertyNameListAsString(zkClient, clusterName, instanceName, PropertyType.CURRENTSTATES, instanceSessionId, MediaType.APPLICATION_JSON); StringRepresentation representation = new StringRepresentation(message, MediaType.APPLICATION_JSON); return representation; }
Example #13
Source File: StateModelsResource.java From helix with Apache License 2.0 | 6 votes |
StringRepresentation getStateModelsRepresentation() throws JsonGenerationException, JsonMappingException, IOException { String clusterName = (String) getRequest().getAttributes().get("clusterName"); ZkClient zkClient = (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT); ClusterSetup setupTool = new ClusterSetup(zkClient); List<String> models = setupTool.getClusterManagementTool().getStateModelDefs(clusterName); ZNRecord modelDefinitions = new ZNRecord("modelDefinitions"); modelDefinitions.setListField("models", models); StringRepresentation representation = new StringRepresentation(ClusterRepresentationUtil.ZNRecordToJson(modelDefinitions), MediaType.APPLICATION_JSON); return representation; }
Example #14
Source File: TestOLAPCubeCountDistinct.java From Cubert with Apache License 2.0 | 6 votes |
@Test void testMixedTypes() throws JsonGenerationException, JsonMappingException, IOException, InterruptedException { // members: srinivas, maneesh, krishna, saurabh, rui // dimensions: country code, number of monitors, vegetarian Object[][] rows = { { 1, 1, (long) 22222222222222L, 1 }, { 2, 1, (long) 22222222222222L, 2 }, { 3, 1, (long) 11111111111111L, 1 }, { 4, 1, (long) 11111111111111L, 2 }, { 5, 2, (long) 22222222222222L, 2 } }; String[] expected = new String[] { "(1,22222222222222,1,1)", "(1,22222222222222,2,1)", "(1,11111111111111,1,1)", "(1,11111111111111,2,1)", "(2,22222222222222,2,1)", "(1,,,4)", "(2,,,1)", "(,11111111111111,,2)", "(,22222222222222,,3)", "(,,1,2)", "(,,2,3)", "(1,11111111111111,,2)", "(1,22222222222222,,2)", "(2,22222222222222,,1)", "(,11111111111111,1,1)", "(,11111111111111,2,1)", "(,22222222222222,1,1)", "(,22222222222222,2,2)", "(1,,1,2)", "(1,,2,2)", "(2,,2,1)", "(,,,5)" }; validate(rows, expected); }
Example #15
Source File: RestDemoServiceIT.java From demo-restWS-spring-jersey-jpa2-hibernate with MIT License | 6 votes |
@Test public void testGetLegacyPodcast() throws JsonGenerationException, JsonMappingException, IOException { ClientConfig clientConfig = new ClientConfig(); clientConfig.register(JacksonFeature.class); Client client = ClientBuilder.newClient(clientConfig); WebTarget webTarget = client .target("http://localhost:8888/demo-rest-spring-jersey-jpa2-hibernate-0.0.1-SNAPSHOT/podcasts/2"); Builder request = webTarget.request(MediaType.APPLICATION_JSON); Response response = request.get(); Assert.assertTrue(response.getStatus() == 200); Podcast podcast = response.readEntity(Podcast.class); ObjectMapper mapper = new ObjectMapper(); System.out .print("Received podcast from database *************************** " + mapper.writerWithDefaultPrettyPrinter() .writeValueAsString(podcast)); }
Example #16
Source File: RestDemoServiceIT.java From demo-rest-jersey-spring with MIT License | 6 votes |
@Test public void testGetLegacyPodcast() throws JsonGenerationException, JsonMappingException, IOException { ClientConfig clientConfig = new ClientConfig(); clientConfig.register(JacksonFeature.class); Client client = ClientBuilder.newClient(clientConfig); WebTarget webTarget = client .target("http://localhost:8888/demo-rest-jersey-spring/legacy/podcasts/2"); Builder request = webTarget.request(MediaType.APPLICATION_JSON); Response response = request.get(); Assert.assertTrue(response.getStatus() == 200); Podcast podcast = response.readEntity(Podcast.class); ObjectMapper mapper = new ObjectMapper(); System.out .print("Received podcast from LEGACY database *************************** " + mapper.writerWithDefaultPrettyPrinter() .writeValueAsString(podcast)); }
Example #17
Source File: TestOLAPCubeCountDistinct.java From Cubert with Apache License 2.0 | 6 votes |
@Test void testLongType() throws JsonGenerationException, JsonMappingException, IOException, InterruptedException { // members: srinivas, maneesh, krishna, saurabh, rui // dimensions: country code, number of monitors, vegetarian Object[][] rows = { { 1, (long) 1, (long) 2, (long) 1 }, { 2, (long) 1, (long) 2, (long) 2 }, { 3, (long) 1, (long) 1, (long) 1 }, { 4, (long) 1, (long) 1, (long) 2 }, { 5, (long) 2, (long) 2, (long) 2 } }; String[] expected = new String[] { "(1,2,1,1)", "(1,2,2,1)", "(1,1,1,1)", "(1,1,2,1)", "(2,2,2,1)", "(1,,,4)", "(2,,,1)", "(,1,,2)", "(,2,,3)", "(,,1,2)", "(,,2,3)", "(1,1,,2)", "(1,2,,2)", "(2,2,,1)", "(,1,1,1)", "(,1,2,1)", "(,2,1,1)", "(,2,2,2)", "(1,,1,2)", "(1,,2,2)", "(2,,2,1)", "(,,,5)" }; validate(rows, expected); }
Example #18
Source File: CoTAdapter.java From defense-solutions-proofs-of-concept with Apache License 2.0 | 6 votes |
private void addVertexToPolygon(double lat, double lon, double hae) throws JsonGenerationException, IOException { if( firstVertex ) { firstVertex = false; cachedLat = lat; cachedLon = lon; cachedHae = hae; firstVertex = false; } generator.writeStartArray(); generator.writeNumber(lon); generator.writeNumber(lat); //generator.writeNumber(hae); generator.writeEndArray(); }
Example #19
Source File: CoTAdapterInbound.java From defense-solutions-proofs-of-concept with Apache License 2.0 | 6 votes |
private void addVertexToPolygon(double lat, double lon, double hae) throws JsonGenerationException, IOException { try { if (firstVertex) { firstVertex = false; cachedLat = lat; cachedLon = lon; cachedHae = hae; firstVertex = false; } generator.writeStartArray(); generator.writeNumber(lon); generator.writeNumber(lat); // generator.writeNumber(hae); generator.writeEndArray(); } catch (Exception e) { log.error(e); log.error(e.getStackTrace()); } }
Example #20
Source File: CoTAdapter.java From defense-solutions-proofs-of-concept with Apache License 2.0 | 6 votes |
private void addVertexToPolygon(double lat, double lon, double hae) throws JsonGenerationException, IOException { if( firstVertex ) { firstVertex = false; cachedLat = lat; cachedLon = lon; cachedHae = hae; firstVertex = false; } generator.writeStartArray(); generator.writeNumber(lon); generator.writeNumber(lat); //generator.writeNumber(hae); generator.writeEndArray(); }
Example #21
Source File: CoTAdapterInbound.java From defense-solutions-proofs-of-concept with Apache License 2.0 | 6 votes |
private void addVertexToPolygon(double lat, double lon, double hae) throws JsonGenerationException, IOException { try { if (firstVertex) { firstVertex = false; cachedLat = lat; cachedLon = lon; cachedHae = hae; firstVertex = false; } generator.writeStartArray(); generator.writeNumber(lon); generator.writeNumber(lat); // generator.writeNumber(hae); generator.writeEndArray(); } catch (Exception e) { log.error(e); log.error(e.getStackTrace()); } }
Example #22
Source File: TestOLAPCubeCountDistinct.java From Cubert with Apache License 2.0 | 6 votes |
@Test void testThreeDimsTeam() throws JsonGenerationException, JsonMappingException, IOException, InterruptedException { Object[][] rows = { { 1, (int) 1, (int) 2, (int) 1 }, { 2, (int) 1, (int) 2, (int) 2 }, { 3, (int) 1, (int) 1, (int) 1 }, { 4, (int) 1, (int) 1, (int) 2 }, { 5, (int) 2, (int) 2, (int) 2 } }; String[] expected = new String[] { "(1,2,1,1)", "(1,2,2,1)", "(1,1,1,1)", "(1,1,2,1)", "(2,2,2,1)", "(1,,,4)", "(2,,,1)", "(,1,,2)", "(,2,,3)", "(,,1,2)", "(,,2,3)", "(1,1,,2)", "(1,2,,2)", "(2,2,,1)", "(,1,1,1)", "(,1,2,1)", "(,2,1,1)", "(,2,2,2)", "(1,,1,2)", "(1,,2,2)", "(2,,2,1)", "(,,,5)" }; validate(rows, expected); }
Example #23
Source File: PodcastRestService.java From demo-restWS-spring-jersey-jpa2-hibernate with MIT License | 6 votes |
@GET @Path("{id}") @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public Response findById(@PathParam("id") Long id) throws JsonGenerationException, JsonMappingException, IOException { Podcast podcastById = podcastDao.getPodcastById(id); if (podcastById != null) { return Response .status(200) .entity(podcastById) .header("Access-Control-Allow-Headers", "X-extra-header") .allow("OPTIONS") .build(); } else { return Response .status(404) .entity("The podcast with the id " + id + " does not exist") .build(); } }
Example #24
Source File: TestOLAPCube.java From Cubert with Apache License 2.0 | 6 votes |
@Test void testGroupingSetsSum() throws JsonGenerationException, JsonMappingException, IOException, InterruptedException { // clickCount // dimensions: country code, number of monitors, vegetarian Object[][] rows = { { 1, (int) 1, (int) 1, (int) 1 }, { 1, (int) 1, (int) 1, (int) 2 }, { 2, (int) 1, (int) 2, (int) 1 }, { 3, (int) 1, (int) 2, (int) 2 }, { 2, (int) 2, (int) 2, (int) 2 } }; String[] expected = new String[] { "(1,,,7)", "(2,,,2)", "(1,1,,2)", "(1,2,,5)", "(2,2,,2)" }; validateGroupingSets(rows, expected, new String[] { "Dim0,Dim1", "Dim0" }); }
Example #25
Source File: TestOperators.java From Cubert with Apache License 2.0 | 5 votes |
@Test // when there are multiple rows in one table public void testHashJoin2() throws JsonGenerationException, JsonMappingException, IOException, InterruptedException { Object[][] rows1 = { { 2 }, { 2 }, { 5 }, { 10 } }; Object[][] rows2 = { { 1 }, { 7 }, { 9 } }; Object[][] expected = {}; Block block1 = new ArrayBlock(Arrays.asList(rows1), new String[] { "a" }); Block block2 = new ArrayBlock(Arrays.asList(rows2), new String[] { "a" }); TupleOperator operator = new HashJoinOperator(); Map<String, Block> input = new HashMap<String, Block>(); input.put("block1", block1); input.put("block2", block2); ObjectMapper mapper = new ObjectMapper(); ObjectNode node = mapper.createObjectNode(); node.put("leftJoinKeys", "a"); node.put("rightJoinKeys", "a"); node.put("leftBlock", "block1"); BlockProperties props = new BlockProperties(null, new BlockSchema("INT block1___a, INT block2___a"), (BlockProperties) null); operator.setInput(input, node, props); Block output = new TupleOperatorBlock(operator, props); ArrayBlock.assertData(output, expected, new String[] { "block1.a", "block2.a" }); }
Example #26
Source File: TestOLAPCube.java From Cubert with Apache License 2.0 | 5 votes |
@Test void testNoOverlap() throws JsonGenerationException, JsonMappingException, IOException, InterruptedException { Object[][] rows = { { 1, (int) 10 }, { 1, (int) 20 }, { 2, (int) 30 }, { 2, (int) 40 }, { 3, (int) 50 } }; String[] expected = new String[] { "(10,1)", "(20,1)", "(30,2)", "(40,2)", "(50,3)", "(,9)" }; validate(rows, expected); }
Example #27
Source File: TestOperators.java From Cubert with Apache License 2.0 | 5 votes |
@Test // when there are multiple rows in one table public void testRightMergeJoin() throws JsonGenerationException, JsonMappingException, IOException, InterruptedException { Object[][] rows1 = { { 0 }, { 2 }, { 2 }, { 5 }, { 10 }, { 100 } }; Object[][] rows2 = { { 1 }, { 2 }, { 7 }, { 9 }, { 100 }, { 100 } }; Object[][] expected = { { null, 1 }, { 2, 2 }, { 2, 2 }, { null, 7 }, { null, 9 }, { 100, 100 }, { 100, 100 } }; Block block1 = new ArrayBlock(Arrays.asList(rows1), new String[] { "a" }); Block block2 = new ArrayBlock(Arrays.asList(rows2), new String[] { "a" }); TupleOperator operator = new MergeJoinOperator(); Map<String, Block> input = new HashMap<String, Block>(); input.put("block1", block1); input.put("block2", block2); ObjectMapper mapper = new ObjectMapper(); ObjectNode node = mapper.createObjectNode(); node.put("leftCubeColumns", "a"); node.put("rightCubeColumns", "a"); node.put("leftBlock", "block1"); node.put("rightBlock", "block2"); node.put("joinType", "right outer"); BlockProperties props = new BlockProperties(null, new BlockSchema("INT block1___a, INT block2___a"), (BlockProperties) null); operator.setInput(input, node, props); Block output = new TupleOperatorBlock(operator, props); ArrayBlock.assertData(output, expected, new String[] { "block1.a", "block2.a" }); }
Example #28
Source File: RestDemoServiceIT.java From demo-rest-jersey-spring with MIT License | 5 votes |
@Test public void testGetPodcasts() throws JsonGenerationException, JsonMappingException, IOException { ClientConfig clientConfig = new ClientConfig(); clientConfig.register(JacksonFeature.class); Client client = ClientBuilder.newClient(clientConfig); WebTarget webTarget = client .target("http://localhost:8888/demo-rest-jersey-spring/podcasts/"); Builder request = webTarget.request(); request.header("Content-type", MediaType.APPLICATION_JSON); Response response = request.get(); Assert.assertTrue(response.getStatus() == 200); List<Podcast> podcasts = response .readEntity(new GenericType<List<Podcast>>() { }); ObjectMapper mapper = new ObjectMapper(); System.out.print(mapper.writerWithDefaultPrettyPrinter() .writeValueAsString(podcasts)); Assert.assertTrue("At least one podcast is present", podcasts.size() > 0); }
Example #29
Source File: ClusterRepresentationUtil.java From helix with Apache License 2.0 | 5 votes |
public static String getInstancePropertyAsString(ZkClient zkClient, String clusterName, PropertyKey propertyKey, MediaType mediaType) throws JsonGenerationException, JsonMappingException, IOException { ZKHelixDataAccessor accessor = new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(zkClient)); ZNRecord records = accessor.getProperty(propertyKey).getRecord(); return ZNRecordToJson(records); }
Example #30
Source File: TestOLAPCubeCountDistinct.java From Cubert with Apache License 2.0 | 5 votes |
@Test void testOneDimension() throws JsonGenerationException, JsonMappingException, IOException, InterruptedException { Object[][] rows = { { 1, (int) 10 }, { 2, (int) 10 }, { 2, (int) 10 } }; String[] expected = new String[] { "(10,2)", "(,2)" }; validate(rows, expected); }