@Test public void testJsonSerialization() throws IOException { ObjectMapper objectMapper = new ObjectMapper(); VmNetworks vmNetworks = new VmNetworks(); NetworkConnection networkConnection = new NetworkConnection(); networkConnection.setMacAddress("mac"); networkConnection.setIsConnected(NetworkConnection.Connected.True); networkConnection.setNetwork("network"); networkConnection.setIpAddress("ip"); vmNetworks.addNetworkConnection(networkConnection); Task task = new Task(); task.setResourceProperties(vmNetworks); String taskString = objectMapper.writeValueAsString(task); Task task1 = objectMapper.readValue(taskString, new com.fasterxml.jackson.core.type.TypeReference<Task>() { }); VmNetworks vmNetworks1 = VmRestApi.parseVmNetworksFromTask(task1); NetworkConnection networkConnection1 = (NetworkConnection) vmNetworks1.getNetworkConnections().toArray()[0]; assertEquals(networkConnection1.getIpAddress(), networkConnection.getIpAddress()); assertEquals(networkConnection1.getMacAddress(), networkConnection.getMacAddress()); assertEquals(networkConnection1.getIsConnected(), networkConnection.getIsConnected()); assertEquals(networkConnection1.getNetmask(), networkConnection.getNetmask()); assertEquals(networkConnection1.getNetwork(), networkConnection.getNetwork()); }
public static VmNetworks parseVmNetworksFromTask(Task task) throws IOException { String json = objectMapper.writeValueAsString(task.getResourceProperties()); return deserializeObjectFromJson(json, new TypeReference<VmNetworks>(){}); }
VmRestApi extends ApiBase implements VmApi { public static VmNetworks parseVmNetworksFromTask(Task task) throws IOException { String json = objectMapper.writeValueAsString(task.getResourceProperties()); return deserializeObjectFromJson(json, new TypeReference<VmNetworks>(){}); } }
VmRestApi extends ApiBase implements VmApi { public static VmNetworks parseVmNetworksFromTask(Task task) throws IOException { String json = objectMapper.writeValueAsString(task.getResourceProperties()); return deserializeObjectFromJson(json, new TypeReference<VmNetworks>(){}); } VmRestApi(RestClient restClient); }
VmRestApi extends ApiBase implements VmApi { public static VmNetworks parseVmNetworksFromTask(Task task) throws IOException { String json = objectMapper.writeValueAsString(task.getResourceProperties()); return deserializeObjectFromJson(json, new TypeReference<VmNetworks>(){}); } VmRestApi(RestClient restClient); @Override String getBasePath(); @Override Vm getVm(String vmId); @Override void getVmAsync(final String vmId, final FutureCallback<Vm>
      responseCallback); @Override ResourceList<Task> getTasksForVm(String vmId); @Override void getTasksForVmAsync(final String vmId,
                                 final FutureCallback<ResourceList<Task>> responseCallback); @Override Task delete(String id); @Override void deleteAsync(final String id, final FutureCallback<Task> responseCallback); @Override Task addTagToVm(String vmId, Tag tag); @Override void addTagToVmAsync(final String vmId, Tag tag, final FutureCallback<Task> responseCallback); @Override Task performStartOperation(String vmId); @Override void performStartOperationAsync(final String vmId,
                                         final FutureCallback<Task> responseCallback); @Override Task performStopOperation(String vmId); @Override void performStopOperationAsync(final String vmId,
                                        final FutureCallback<Task> responseCallback); @Override Task performRestartOperation(String vmId); @Override void performRestartOperationAsync(final String vmId,
                                           final FutureCallback<Task> responseCallback); @Override Task performResumeOperation(String vmId); @Override void performResumeOperationAsync(final String vmId,
                                          final FutureCallback<Task> responseCallback); @Override Task performSuspendOperation(String vmId); @Override void performSuspendOperationAsync(final String vmId,
                                           final FutureCallback<Task> responseCallback); @Override Task attachDisk(String vmId, VmDiskOperation vmDiskOperation); @Override void attachDiskAsync(final String vmId, VmDiskOperation vmDiskOperation,
                              final FutureCallback<Task> responseCallback); @Override Task detachDisk(String vmId, VmDiskOperation vmDiskOperation); @Override void detachDiskAsync(final String vmId, VmDiskOperation vmDiskOperation,
                              final FutureCallback<Task> responseCallback); @Override Task uploadAndAttachIso(String vmId, String inputFileName); @Override Task detachIso(String vmId); @Override void detachIsoAsync(final String vmId, final FutureCallback<Task> responseCallback); @Override Task getNetworks(String vmId); @Override void getNetworksAsync(String vmId, FutureCallback<Task> responseCallback); static VmNetworks parseVmNetworksFromTask(Task task); @Override Task setMetadata(final String vmId, final VmMetadata metadata); @Override void setMetadataAsync(
      final String vmId,
      final VmMetadata metadata,
      final FutureCallback<Task> responseCallback); }
VmRestApi extends ApiBase implements VmApi { public static VmNetworks parseVmNetworksFromTask(Task task) throws IOException { String json = objectMapper.writeValueAsString(task.getResourceProperties()); return deserializeObjectFromJson(json, new TypeReference<VmNetworks>(){}); } VmRestApi(RestClient restClient); @Override String getBasePath(); @Override Vm getVm(String vmId); @Override void getVmAsync(final String vmId, final FutureCallback<Vm>
      responseCallback); @Override ResourceList<Task> getTasksForVm(String vmId); @Override void getTasksForVmAsync(final String vmId,
                                 final FutureCallback<ResourceList<Task>> responseCallback); @Override Task delete(String id); @Override void deleteAsync(final String id, final FutureCallback<Task> responseCallback); @Override Task addTagToVm(String vmId, Tag tag); @Override void addTagToVmAsync(final String vmId, Tag tag, final FutureCallback<Task> responseCallback); @Override Task performStartOperation(String vmId); @Override void performStartOperationAsync(final String vmId,
                                         final FutureCallback<Task> responseCallback); @Override Task performStopOperation(String vmId); @Override void performStopOperationAsync(final String vmId,
                                        final FutureCallback<Task> responseCallback); @Override Task performRestartOperation(String vmId); @Override void performRestartOperationAsync(final String vmId,
                                           final FutureCallback<Task> responseCallback); @Override Task performResumeOperation(String vmId); @Override void performResumeOperationAsync(final String vmId,
                                          final FutureCallback<Task> responseCallback); @Override Task performSuspendOperation(String vmId); @Override void performSuspendOperationAsync(final String vmId,
                                           final FutureCallback<Task> responseCallback); @Override Task attachDisk(String vmId, VmDiskOperation vmDiskOperation); @Override void attachDiskAsync(final String vmId, VmDiskOperation vmDiskOperation,
                              final FutureCallback<Task> responseCallback); @Override Task detachDisk(String vmId, VmDiskOperation vmDiskOperation); @Override void detachDiskAsync(final String vmId, VmDiskOperation vmDiskOperation,
                              final FutureCallback<Task> responseCallback); @Override Task uploadAndAttachIso(String vmId, String inputFileName); @Override Task detachIso(String vmId); @Override void detachIsoAsync(final String vmId, final FutureCallback<Task> responseCallback); @Override Task getNetworks(String vmId); @Override void getNetworksAsync(String vmId, FutureCallback<Task> responseCallback); static VmNetworks parseVmNetworksFromTask(Task task); @Override Task setMetadata(final String vmId, final VmMetadata metadata); @Override void setMetadataAsync(
      final String vmId,
      final VmMetadata metadata,
      final FutureCallback<Task> responseCallback);  }