EnableStreamingTaskParameters { public static EnableStreamingTaskParameters deserialize(String taskParameters) { JaxbJsonSerializer<EnableStreamingTaskParameters> serializer = new JaxbJsonSerializer<>(EnableStreamingTaskParameters.class); try { EnableStreamingTaskParameters params = serializer.deserialize(taskParameters); if (null == params.getSpaceId() || params.getSpaceId().isEmpty()) { throw new TaskDataException( "Task parameter values may not be empty"); } return params; } catch (IOException e) { throw new TaskDataException( "Unable to parse task parameters due to: " + e.getMessage()); } } EnableStreamingTaskParameters(); String getSpaceId(); void setSpaceId(String spaceId); boolean isSecure(); void setSecure(boolean secure); List<String> getAllowedOrigins(); void setAllowedOrigins(List<String> allowedOrigins); String serialize(); static EnableStreamingTaskParameters deserialize(String taskParameters);  }
@Test public void testDeserialize() { String taskParamsSerialized = "{\"spaceId\" : \"" + spaceId + "\"," + " \"secure\" : \"" + secure + "\"}"; EnableStreamingTaskParameters taskParams = EnableStreamingTaskParameters.deserialize(taskParamsSerialized); assertEquals(spaceId, taskParams.getSpaceId()); assertEquals(secure, taskParams.isSecure()); taskParamsSerialized = "{\"spaceId\" : \"\"," + " \"secure\" : \"\"}"; try { EnableStreamingTaskParameters.deserialize(taskParamsSerialized); fail("Exception expected: Invalid params"); } catch (TaskDataException e) { } try { EnableStreamingTaskParameters.deserialize(""); fail("Exception expected: Invalid params"); } catch (TaskDataException e) { } }