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