GetSignedCookiesUrlTaskParameters { public static GetSignedCookiesUrlTaskParameters deserialize(String taskParameters) { JaxbJsonSerializer<GetSignedCookiesUrlTaskParameters> serializer = new JaxbJsonSerializer<>(GetSignedCookiesUrlTaskParameters.class); try { GetSignedCookiesUrlTaskParameters 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.getRedirectUrl() || params.getRedirectUrl().isEmpty()) { throw new TaskDataException( "Task parameter 'redirectUrl' may not be empty"); } return params; } catch (IOException e) { throw new TaskDataException( "Unable to parse task parameters due to: " + e.getMessage()); } } GetSignedCookiesUrlTaskParameters(); String getSpaceId(); void setSpaceId(String spaceId); int getMinutesToExpire(); void setMinutesToExpire(int minutesToExpire); String getIpAddress(); void setIpAddress(String ipAddress); String getRedirectUrl(); void setRedirectUrl(String redirectUrl); String serialize(); static GetSignedCookiesUrlTaskParameters deserialize(String taskParameters); static final int USE_DEFAULT_MINUTES_TO_EXPIRE; }
@Test public void testDeserialize() { String taskParamsSerialized = "{\"spaceId\" : \"" + spaceId + "\"," + " \"minutesToExpire\" : " + minutesToExpire + "," + " \"ipAddress\" : \"" + ipAddress + "\"," + " \"redirectUrl\" : \"" + redirectUrl + "\"}"; GetSignedCookiesUrlTaskParameters taskParams = GetSignedCookiesUrlTaskParameters.deserialize(taskParamsSerialized); assertEquals(spaceId, taskParams.getSpaceId()); assertEquals(minutesToExpire, taskParams.getMinutesToExpire()); assertEquals(ipAddress, taskParams.getIpAddress()); assertEquals(redirectUrl, taskParams.getRedirectUrl()); taskParamsSerialized = "{\"spaceId\" : \"\"," + " \"minutesToExpire\" : " + minutesToExpire + "," + " \"ipAddress\" : \"" + ipAddress + "\"," + " \"redirectUrl\" : \"" + redirectUrl + "\"}"; try { GetSignedCookiesUrlTaskParameters.deserialize(taskParamsSerialized); fail("Exception expected: Invalid params"); } catch (TaskDataException e) { } taskParamsSerialized = "{\"spaceId\" : \"" + spaceId + "\"," + " \"minutesToExpire\" : " + minutesToExpire + "," + " \"ipAddress\" : \"" + ipAddress + "\"," + " \"redirectUrl\" : \"\"}"; try { GetSignedCookiesUrlTaskParameters.deserialize(taskParamsSerialized); fail("Exception expected: Invalid params"); } catch (TaskDataException e) { } taskParamsSerialized = "{\"spaceId\" : \"\"," + " \"minutesToExpire\" : \"\"," + " \"ipAddress\" : \"\"," + " \"redirectUrl\" : \"\"}"; try { GetSignedCookiesUrlTaskParameters.deserialize(taskParamsSerialized); fail("Exception expected: Invalid params"); } catch (TaskDataException e) { } try { GetSignedCookiesUrlTaskParameters.deserialize(""); fail("Exception expected: Invalid params"); } catch (TaskDataException e) { } }