コード例 #1
0
 @Inject
 BaseStorageResponseHandler(DateCodecFactory dateCodec) {
   this.dateCodec = dateCodec.iso8601();
   this.builder = Storage.builder();
   this.serverIds = Lists.newArrayList();
 }
コード例 #2
0
  @Test
  public void testParseResponseFromGetDataCenter() {
    ParseSax<DataCenter> parser = createParser();

    DataCenter actual = parser.parse(payloadFromResource("/datacenter/datacenter.xml"));
    assertNotNull(actual, "Parsed content returned null");

    DateService dateParser = createDateParser();

    DataCenter expected =
        DataCenter.builder()
            .id("12345678-abcd-efgh-ijkl-987654321000")
            .version(10)
            .name("JClouds-DC")
            .state(ProvisioningState.AVAILABLE)
            .location(Location.US_LAS)
            .servers(
                ImmutableList.<Server>of(
                    Server.builder()
                        .dataCenter(
                            DataCenter.builder()
                                .id("12345678-abcd-efgh-ijkl-987654321000")
                                .version(10)
                                .build())
                        .id("qqqqqqqq-wwww-eeee-rrrr-tttttttttttt")
                        .name("jnode1")
                        .cores(4)
                        .ram(4096)
                        .hasInternetAccess(true)
                        .state(ProvisioningState.AVAILABLE)
                        .status(Server.Status.RUNNING)
                        .creationTime(
                            dateParser.iso8601DateOrSecondsDateParse("2014-12-04T07:09:23.138Z"))
                        .lastModificationTime(
                            dateParser.iso8601DateOrSecondsDateParse("2014-12-12T03:08:35.629Z"))
                        .osType(OsType.LINUX)
                        .availabilityZone(AvailabilityZone.AUTO)
                        .isCpuHotPlug(true)
                        .isRamHotPlug(true)
                        .isNicHotPlug(true)
                        .isNicHotUnPlug(true)
                        .isDiscVirtioHotPlug(true)
                        .isDiscVirtioHotUnPlug(true)
                        .storages(
                            ImmutableList.<Storage>of(
                                Storage.builder()
                                    .bootDevice(Boolean.TRUE)
                                    .id("ssssssss-aaaa-ffff-gggg-hhhhhhhhhhhh")
                                    .busType(Storage.BusType.VIRTIO)
                                    .deviceNumber(1)
                                    .size(40f)
                                    .name("jnode1-disk1")
                                    .build()))
                        .nics(
                            ImmutableList.<Nic>of(
                                Nic.builder()
                                    .dataCenterId("12345678-abcd-efgh-ijkl-987654321000")
                                    .id("zzzzzzzz-xxxx-cccc-vvvv-bbbbbbbbbbbb")
                                    .lanId(1)
                                    .internetAccess(true)
                                    .serverId("qqqqqqqq-wwww-eeee-rrrr-tttttttttttt")
                                    .ips(ImmutableList.of("202.94.38.12"))
                                    .macAddress("02:01:09:cd:f0:b0")
                                    .firewall(
                                        Firewall.builder()
                                            .active(false)
                                            .id("llllllll-kkkk-jjjj-hhhh-gggggggggggg")
                                            .nicId("zzzzzzzz-xxxx-cccc-vvvv-bbbbbbbbbbbb")
                                            .state(ProvisioningState.AVAILABLE)
                                            .build())
                                    .dhcpActive(true)
                                    .gatewayIp("202.94.38.1")
                                    .state(ProvisioningState.AVAILABLE)
                                    .build()))
                        .build()))
            .storages(
                ImmutableList.<Storage>of(
                    Storage.builder()
                        .id("ssssssss-aaaa-ffff-gggg-hhhhhhhhhhhh")
                        .size(40)
                        .name("jnode1-disk1")
                        .state(ProvisioningState.AVAILABLE)
                        .creationTime(
                            dateParser.iso8601DateOrSecondsDateParse("2014-12-04T07:09:23.138Z"))
                        .lastModificationTime(
                            dateParser.iso8601DateOrSecondsDateParse("2014-12-12T03:14:48.316Z"))
                        .serverIds(ImmutableList.of("qqqqqqqq-wwww-eeee-rrrr-tttttttttttt"))
                        .build()))
            .build();
    assertEquals(actual, expected);
  }