@Test(expected = ValidationException.class) public void testLongDescription() { final String description = "0123456789"; context.checking(new Expectations() { { allowing(actionContext).getParams(); will(returnValue(fsdto)); allowing(fsdto).getDescription(); will(returnValue(description)); } }); sut.validate(actionContext); context.assertIsSatisfied(); }
@Override public void validate(final ActionContext inActionContext) throws ValidationException { FeaturedStreamDTO dto = (FeaturedStreamDTO) inActionContext.getParams(); String description = dto.getDescription(); if (StringUtils.isEmpty(description) || (description.length() > maxLength)) { throw new ValidationException("Description must be present and less than " + maxLength + " characters"); } StreamScope streamScope = streamScopeMapper.execute(new FindByIdRequest("StreamScope", dto.getStreamId())); if (streamScope == null) { throw new ValidationException("Stream not found"); } inActionContext.getState().put("streamScope", streamScope); if (streamScope.getScopeType() != ScopeType.PERSON && streamScope.getScopeType() != ScopeType.GROUP) { throw new ValidationException("Only person and group streams supported."); } }
AddFeaturedStreamValidation implements ValidationStrategy<ActionContext> { @Override public void validate(final ActionContext inActionContext) throws ValidationException { FeaturedStreamDTO dto = (FeaturedStreamDTO) inActionContext.getParams(); String description = dto.getDescription(); if (StringUtils.isEmpty(description) || (description.length() > maxLength)) { throw new ValidationException("Description must be present and less than " + maxLength + " characters"); } StreamScope streamScope = streamScopeMapper.execute(new FindByIdRequest("StreamScope", dto.getStreamId())); if (streamScope == null) { throw new ValidationException("Stream not found"); } inActionContext.getState().put("streamScope", streamScope); if (streamScope.getScopeType() != ScopeType.PERSON && streamScope.getScopeType() != ScopeType.GROUP) { throw new ValidationException("Only person and group streams supported."); } } }
AddFeaturedStreamValidation implements ValidationStrategy<ActionContext> { @Override public void validate(final ActionContext inActionContext) throws ValidationException { FeaturedStreamDTO dto = (FeaturedStreamDTO) inActionContext.getParams(); String description = dto.getDescription(); if (StringUtils.isEmpty(description) || (description.length() > maxLength)) { throw new ValidationException("Description must be present and less than " + maxLength + " characters"); } StreamScope streamScope = streamScopeMapper.execute(new FindByIdRequest("StreamScope", dto.getStreamId())); if (streamScope == null) { throw new ValidationException("Stream not found"); } inActionContext.getState().put("streamScope", streamScope); if (streamScope.getScopeType() != ScopeType.PERSON && streamScope.getScopeType() != ScopeType.GROUP) { throw new ValidationException("Only person and group streams supported."); } } AddFeaturedStreamValidation(final int inMaxLength,
            final DomainMapper<FindByIdRequest, StreamScope> inStreamScopeMapper); }
AddFeaturedStreamValidation implements ValidationStrategy<ActionContext> { @Override public void validate(final ActionContext inActionContext) throws ValidationException { FeaturedStreamDTO dto = (FeaturedStreamDTO) inActionContext.getParams(); String description = dto.getDescription(); if (StringUtils.isEmpty(description) || (description.length() > maxLength)) { throw new ValidationException("Description must be present and less than " + maxLength + " characters"); } StreamScope streamScope = streamScopeMapper.execute(new FindByIdRequest("StreamScope", dto.getStreamId())); if (streamScope == null) { throw new ValidationException("Stream not found"); } inActionContext.getState().put("streamScope", streamScope); if (streamScope.getScopeType() != ScopeType.PERSON && streamScope.getScopeType() != ScopeType.GROUP) { throw new ValidationException("Only person and group streams supported."); } } AddFeaturedStreamValidation(final int inMaxLength,
            final DomainMapper<FindByIdRequest, StreamScope> inStreamScopeMapper); @Override void validate(final ActionContext inActionContext); }
AddFeaturedStreamValidation implements ValidationStrategy<ActionContext> { @Override public void validate(final ActionContext inActionContext) throws ValidationException { FeaturedStreamDTO dto = (FeaturedStreamDTO) inActionContext.getParams(); String description = dto.getDescription(); if (StringUtils.isEmpty(description) || (description.length() > maxLength)) { throw new ValidationException("Description must be present and less than " + maxLength + " characters"); } StreamScope streamScope = streamScopeMapper.execute(new FindByIdRequest("StreamScope", dto.getStreamId())); if (streamScope == null) { throw new ValidationException("Stream not found"); } inActionContext.getState().put("streamScope", streamScope); if (streamScope.getScopeType() != ScopeType.PERSON && streamScope.getScopeType() != ScopeType.GROUP) { throw new ValidationException("Only person and group streams supported."); } } AddFeaturedStreamValidation(final int inMaxLength,
            final DomainMapper<FindByIdRequest, StreamScope> inStreamScopeMapper); @Override void validate(final ActionContext inActionContext);  }