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