GetHlsUrlTaskParameters { public static GetHlsUrlTaskParameters deserialize(String taskParameters) { JaxbJsonSerializer<GetHlsUrlTaskParameters> serializer = new JaxbJsonSerializer<>(GetHlsUrlTaskParameters.class); try { GetHlsUrlTaskParameters params = serializer.deserialize(taskParameters); if (null == params.getSpaceId() || params.getSpaceId().isEmpty()) { throw new TaskDataException( "Task parameter 'spaceId' may not be empty"); } else if (null == params.getContentId() || params.getContentId().isEmpty()) { throw new TaskDataException( "Task parameter 'contentId' may not be empty"); } return params; } catch (IOException e) { throw new TaskDataException( "Unable to parse task parameters due to: " + e.getMessage()); } } GetHlsUrlTaskParameters(); String getSpaceId(); void setSpaceId(String spaceId); String getContentId(); void setContentId(String contentId); String serialize(); static GetHlsUrlTaskParameters deserialize(String taskParameters);  }
@Test public void testDeserialize() { String taskParamsSerialized = "{\"spaceId\" : \"" + spaceId + "\"," + " \"contentId\" : \"" + contentId + "\"}"; GetHlsUrlTaskParameters taskParams = GetHlsUrlTaskParameters.deserialize(taskParamsSerialized); assertEquals(spaceId, taskParams.getSpaceId()); assertEquals(contentId, taskParams.getContentId()); taskParamsSerialized = "{\"spaceId\" : \"\"," + " \"contentId\" : \"" + contentId + "\"}"; try { GetHlsUrlTaskParameters.deserialize(taskParamsSerialized); fail("Exception expected: Invalid params"); } catch (TaskDataException e) { } taskParamsSerialized = "{\"spaceId\" : \"" + spaceId + "\"," + " \"contentId\" : \"\"}"; try { GetHlsUrlTaskParameters.deserialize(taskParamsSerialized); fail("Exception expected: Invalid params"); } catch (TaskDataException e) { } taskParamsSerialized = "{\"spaceId\" : \"\"," + " \"contentId\" : \"\"}"; try { GetHlsUrlTaskParameters.deserialize(taskParamsSerialized); fail("Exception expected: Invalid params"); } catch (TaskDataException e) { } try { GetHlsUrlTaskParameters.deserialize(""); fail("Exception expected: Invalid params"); } catch (TaskDataException e) { } }