GetRestoreTaskParameters extends BaseDTO { public static GetRestoreTaskParameters deserialize(String taskParameters) { JaxbJsonSerializer<GetRestoreTaskParameters> serializer = new JaxbJsonSerializer<>(GetRestoreTaskParameters.class); try { GetRestoreTaskParameters params = serializer.deserialize(taskParameters); if (StringUtils.isBlank(params.getSnapshotId()) && StringUtils.isBlank(params.getRestoreId())) { throw new SnapshotDataException("Task parameter values may not be empty"); } return params; } catch (IOException e) { throw new SnapshotDataException( "Unable to parse task parameters due to: " + e.getMessage()); } }  String getSnapshotId(); void setSnapshotId(String snapshotId); String getRestoreId(); void setRestoreId(String restoreId); String serialize(); static GetRestoreTaskParameters deserialize(String taskParameters);  }
@Test public void testDeserialize() { String taskParamsSerialized = "{\"snapshotId\" : \"snapshot-id\", \"restoreId\" : \"\"}"; GetRestoreTaskParameters taskParams = GetRestoreTaskParameters.deserialize(taskParamsSerialized); assertEquals("snapshot-id", taskParams.getSnapshotId()); try { GetRestoreTaskParameters.deserialize(""); fail("Exception expected: Invalid params"); } catch (SnapshotDataException e) { } taskParamsSerialized = "{\"snapshotId\" : \"\", \"restoreId\" : \"101\"}"; taskParams = GetRestoreTaskParameters.deserialize(taskParamsSerialized); assertEquals("101", taskParams.getRestoreId()); try { GetRestoreTaskParameters.deserialize(""); fail("Exception expected: Invalid params"); } catch (SnapshotDataException e) { } }
@Test public void testSnapshotIdAndRestoreIdMayNotBeNonNullAtTheSameTime() { try { GetRestoreTaskParameters.deserialize("{\"snapshotId\" : \"snapshot-id\", \"restoreId\" : \"101\"}"); fail("Exception expected: Invalid params"); } catch (SnapshotDataException e) { } }
@Test public void testSnapshotIdAndRestoreIdMayNotBeNullAtTheSameTime() { try { GetRestoreTaskParameters.deserialize("{\"snapshotId\" : \"\", \"restoreId\" : \"\"}"); fail("Exception expected: Invalid params"); } catch (SnapshotDataException e) { } }