@Test
@Ignore
public void testValidation() throws Exception {
JSONObject json = new JSONObject();
ConstraintViolationExceptionResponseDTO exceptionDTO;
String req = makeRequest(connectionsBaseUrl, "POST", null, authnToken);
exceptionDTO = jsonToObject(req,
TypeFactory.defaultInstance().constructType(ConstraintViolationExceptionResponseDTO.class));
assertEquals(3, exceptionDTO.getViolations().keySet().size());
// Test invalid name
json.put("alias", "a");
exceptionDTO = jsonToObject(makeRequest(connectionsBaseUrl, "POST", json, authnToken),
TypeFactory.defaultInstance().constructType(ConstraintViolationExceptionResponseDTO.class));
assertEquals(3, exceptionDTO.getViolations().keySet().size());
json.put("alias", "GitHub Feed");
exceptionDTO = jsonToObject(makeRequest(connectionsBaseUrl, "POST", json, authnToken),
TypeFactory.defaultInstance().constructType(ConstraintViolationExceptionResponseDTO.class));
assertEquals(2, exceptionDTO.getViolations().keySet().size());
json.put("type", FeedProvider.TYPE);
exceptionDTO = jsonToObject(makeRequest(connectionsBaseUrl, "POST", json, authnToken),
TypeFactory.defaultInstance().constructType(ConstraintViolationExceptionResponseDTO.class));
assertEquals(1, exceptionDTO.getViolations().keySet().size());
// Test invalid url
json.put("url", "h:/feeds.feedburner.com/github");
exceptionDTO = jsonToObject(makeRequest(connectionsBaseUrl, "POST", json, authnToken),
TypeFactory.defaultInstance().constructType(ConstraintViolationExceptionResponseDTO.class));
assertEquals(1, exceptionDTO.getViolations().keySet().size());
json.put("url", sampleFeedUri);
// Test invalid description
int maxLength = 256;
StringBuilder desc = new StringBuilder();
for (int i = 0; i <= maxLength; i++) {
desc.append("X");
}
json.put("description", desc.toString());
json.put("providerId", FeedType.RSS.toString());
exceptionDTO = jsonToObject(makeRequest(connectionsBaseUrl, "POST", json, authnToken),
TypeFactory.defaultInstance().constructType(ConstraintViolationExceptionResponseDTO.class));
assertEquals(1, exceptionDTO.getViolations().keySet().size());
json.put("description", "Valid description.");
try {
ConnectionResponseDTO connectionResponseDTO = jsonToObject(makeRequest(connectionsBaseUrl, "POST", json, authnToken),