GetSnapshotTaskParameters extends BaseDTO { public static GetSnapshotTaskParameters deserialize(String taskParameters) { JaxbJsonSerializer<GetSnapshotTaskParameters> serializer = new JaxbJsonSerializer<>(GetSnapshotTaskParameters.class); try { GetSnapshotTaskParameters params = serializer.deserialize(taskParameters); if (null == params.getSnapshotId() || params.getSnapshotId().isEmpty()) { 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 serialize(); static GetSnapshotTaskParameters deserialize(String taskParameters);  }
@Test public void testDeserialize() { String taskParamsSerialized = "{\"snapshotId\" : \"snapshot-id\"}"; GetSnapshotTaskParameters taskParams = GetSnapshotTaskParameters.deserialize(taskParamsSerialized); assertEquals("snapshot-id", taskParams.getSnapshotId()); taskParamsSerialized = "{\"snapshotId\" : \"\"}"; try { GetSnapshotTaskParameters.deserialize(taskParamsSerialized); fail("Exception expected: Invalid params"); } catch (SnapshotDataException e) { } try { GetSnapshotTaskParameters.deserialize(""); fail("Exception expected: Invalid params"); } catch (SnapshotDataException e) { } }