Package org.apache.ambari.server.api.services.serializers

Examples of org.apache.ambari.server.api.services.serializers.ResultSerializer.serialize()


    }

    ResultSerializer serializer = mediaType == null ? getResultSerializer() : getResultSerializer(mediaType);

    Response.ResponseBuilder builder = Response.status(result.getStatus().getStatusCode()).entity(
        serializer.serialize(result));

    if (mediaType != null) {
      builder.type(mediaType);
    }
View Full Code Here


    if (mediaType.equals(MediaType.TEXT_PLAIN_TYPE)){
      return new ResultSerializer() {
        @Override
        public Object serialize(Result result) {
          return serializer.serialize(result).toString();
        }

        @Override
        public Object serializeError(ResultStatus error) {
          return serializer.serializeError(error).toString();
View Full Code Here

      };
    } else if (mediaType.equals(MediaType.APPLICATION_JSON_TYPE)){
      return new ResultSerializer() {
        @Override
        public Object serialize(Result result) {
          return JSON.parse(serializer.serialize(result).toString());
        }

        @Override
        public Object serializeError(ResultStatus error) {
          return JSON.parse(serializer.serializeError(error).toString());
View Full Code Here

    // get resource
    ViewSubResourceService service = new ViewSubResourceService(type, viewInstanceEntity);

    ResultSerializer serializer = service.getResultSerializer(MediaType.TEXT_PLAIN_TYPE);

    Object o = serializer.serialize(result);

    String expected = "{\n" +
        "  \"href\" : \"this is an href\",\n" +
        "  \"prop2\" : \"value2\",\n" +
        "  \"prop1\" : \"value1\",\n" +
View Full Code Here

    // get resource
    ViewSubResourceService service = new ViewSubResourceService(type, viewInstanceEntity);

    ResultSerializer serializer = service.getResultSerializer(MediaType.APPLICATION_JSON_TYPE);

    Object o = serializer.serialize(result);

    assertTrue(o instanceof Map);
    Map map = (Map) o;
    assertEquals(4, map.size());
    assertEquals("value1", map.get("prop1"));
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.