Package com.google.collide.dtogen.definitions

Examples of com.google.collide.dtogen.definitions.ComplicatedDto


    @SuppressWarnings("unchecked")
    JsoArray<JsoArray<SimpleEnum>> arrArrEnum =
        JsoArray.from(JsoArray.from(SimpleEnum.ONE, SimpleEnum.TWO, SimpleEnum.THREE),
            JsoArray.from(SimpleEnum.TWO, SimpleEnum.THREE), JsoArray.from(SimpleEnum.THREE));

    ComplicatedDto dto =
        ComplicatedDtoImpl.make().setIntId(intId).setMap(JsoStringMap.<SimpleDto>create())
            .setSimpleDtos(JsoArray.<SimpleDto>create()).setFooStrings(JsoArray.<String>create())
            .setArrayOfArrayOfEnum(arrArrEnum);

    dto.getFooStrings().add(fooString);
    dto.getSimpleDtos().add(simpleDto);

    assertEquals(intId, dto.getIntId());
    assertEquals(fooString, dto.getFooStrings().get(0));
    assertEquals(simpleDto, dto.getSimpleDtos().get(0));
    assertTrue(areArraysEqual(arrArrEnum, dto.getArrayOfArrayOfEnum()));
    assertEquals(ComplicatedDto.TYPE, dto.getType());
  }
View Full Code Here


    dtoImpl.getSimpleDtos().add(simpleDto);
    dtoImpl.getMap().put(fooString, simpleDto);

    // Check to make sure things are in a sane state.
    ComplicatedDto dto = dtoImpl;
    assertEquals(intId, dto.getIntId());
    assertEquals(fooString, dto.getFooStrings().get(0));
    // Should be reference equal initially.
    assertEquals(dto.getSimpleDtos().get(0), simpleDto);
    assertEquals(dto.getMap().get(fooString), simpleDto);
    assertEquals(ComplicatedDto.TYPE, dto.getType());

    // Make it json and pull it back out.
    Gson gson = new Gson();
    String serialized = dtoToJson(gson, dtoImpl);
    ComplicatedDtoImpl deserialized = ComplicatedDtoImpl.fromJsonString(serialized);

    // Test correctness of JSON serialization.
    assertEquals(serialized, dtoImpl.toJson());

    assertEquals(intId, deserialized.getIntId());
    assertEquals(fooString, deserialized.getFooStrings().get(0));
    assertEquals(ComplicatedDto.TYPE, deserialized.getType());

    // Pull it out using the DTO's deserializer.
    JsonElement jsonElement = new JsonParser().parse(serialized);
    ComplicatedDtoImpl deserialized2 = ComplicatedDtoImpl.fromJsonElement(jsonElement);
    assertEquals(intId, deserialized2.getIntId());
    assertEquals(fooString, deserialized2.getFooStrings().get(0));
    assertEquals(ComplicatedDto.TYPE, deserialized2.getType());

    // Verify that the hasFields() are correct when using the DTO's deserializer.
    assertTrue(deserialized2.hasIntId());

    // Check that the SimpleDto object looks correct.
    checkSimpleDto(dto.getSimpleDtos().get(0), simpleDto.getName(), simpleDto.iDontStartWithGet());
    checkSimpleDto(dto.getMap().get(fooString), simpleDto.getName(), simpleDto.iDontStartWithGet());
  }
View Full Code Here

    // Make it json and pull it back out.
    Gson gson = new GsonBuilder().serializeNulls().create();
    String serialized = dtoImpl.toJson();
    assertEquals(dtoToJson(gson, dtoImpl), serialized);

    ComplicatedDto dto = ComplicatedDtoImpl.fromJsonString(serialized);
    assertEquals(1, dto.getIntId());
    assertNull(dto.getSimpleEnum());
  }
View Full Code Here

TOP

Related Classes of com.google.collide.dtogen.definitions.ComplicatedDto

Copyright © 2018 www.massapicom. 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.