use of com.blackducksoftware.integration.hub.alert.web.ObjectTransformer in project hub-alert by blackducksoftware.
the class GlobalSchedulingConfigActionsTest method validateConfigWithValidArgsTest.
@Test
public void validateConfigWithValidArgsTest() {
final GlobalSchedulingConfigActions configActions = new GlobalSchedulingConfigActions(null, null, null, null, new ObjectTransformer(), null, null, null);
final GlobalSchedulingConfigRestModel restModel = getGlobalRestModelMockUtil().createGlobalRestModel();
String validationString = null;
AlertFieldException caughtException = null;
try {
validationString = configActions.validateConfig(restModel);
} catch (final AlertFieldException e) {
caughtException = e;
}
assertNull(caughtException);
assertEquals("Valid", validationString);
}
use of com.blackducksoftware.integration.hub.alert.web.ObjectTransformer in project hub-alert by blackducksoftware.
the class GlobalSchedulingConfigActionsTest method testInvalidConfig.
@Test
@Override
public void testInvalidConfig() {
final String invalidCron = "invalid";
final GlobalSchedulingConfigActions configActions = new GlobalSchedulingConfigActions(null, null, null, null, new ObjectTransformer(), null, null, null);
GlobalSchedulingConfigRestModel restModel = new GlobalSchedulingConfigRestModel("1", invalidCron, invalidCron, invalidCron, invalidCron, invalidCron);
AlertFieldException caughtException = null;
try {
configActions.validateConfig(restModel);
} catch (final AlertFieldException e) {
caughtException = e;
}
assertNotNull(caughtException);
assertEquals("Must be a number between 0 and 23", caughtException.getFieldErrors().get("dailyDigestHourOfDay"));
assertEquals("Must be a number between 1 and 7", caughtException.getFieldErrors().get("purgeDataFrequencyDays"));
assertEquals(2, caughtException.getFieldErrors().size());
restModel = new GlobalSchedulingConfigRestModel("1", "-1", "-1", "-1", "-1", "-1");
caughtException = null;
try {
configActions.validateConfig(restModel);
} catch (final AlertFieldException e) {
caughtException = e;
}
assertNotNull(caughtException);
assertEquals("Must be a number between 0 and 23", caughtException.getFieldErrors().get("dailyDigestHourOfDay"));
assertEquals("Must be a number between 1 and 7", caughtException.getFieldErrors().get("purgeDataFrequencyDays"));
assertEquals(2, caughtException.getFieldErrors().size());
restModel = new GlobalSchedulingConfigRestModel("1", "100000", "100000", "100000", "100000", "100000");
caughtException = null;
try {
configActions.validateConfig(restModel);
} catch (final AlertFieldException e) {
caughtException = e;
}
assertNotNull(caughtException);
assertEquals("Must be a number less than 24", caughtException.getFieldErrors().get("dailyDigestHourOfDay"));
assertEquals("Must be a number less than 8", caughtException.getFieldErrors().get("purgeDataFrequencyDays"));
assertEquals(2, caughtException.getFieldErrors().size());
restModel = new GlobalSchedulingConfigRestModel("1", "", "", "", "", "");
caughtException = null;
try {
configActions.validateConfig(restModel);
} catch (final AlertFieldException e) {
caughtException = e;
}
assertNotNull(caughtException);
assertEquals("Must be a number between 0 and 23", caughtException.getFieldErrors().get("dailyDigestHourOfDay"));
assertEquals("Must be a number between 1 and 7", caughtException.getFieldErrors().get("purgeDataFrequencyDays"));
assertEquals(2, caughtException.getFieldErrors().size());
}
use of com.blackducksoftware.integration.hub.alert.web.ObjectTransformer in project hub-alert by blackducksoftware.
the class ControllerHandlerTest method testCreateResponse.
@Test
public void testCreateResponse() {
final ObjectTransformer objectTransformer = new ObjectTransformer();
final ControllerHandlerTestObject controllerHandlerTestObject = new ControllerHandlerTestObject(objectTransformer);
final ResponseEntity<String> responseEntity = controllerHandlerTestObject.createResponse(HttpStatus.CHECKPOINT, "Test");
assertEquals(HttpStatus.CHECKPOINT, responseEntity.getStatusCode());
assertEquals("{\"id\":-1,\"message\":\"Test\"}", responseEntity.getBody());
}
use of com.blackducksoftware.integration.hub.alert.web.ObjectTransformer in project hub-alert by blackducksoftware.
the class ControllerHandlerTest method testCreateResponseWithStringID.
@Test
public void testCreateResponseWithStringID() {
final ObjectTransformer objectTransformer = new ObjectTransformer();
final ControllerHandlerTestObject controllerHandlerTestObject = new ControllerHandlerTestObject(objectTransformer);
final ResponseEntity<String> responseEntity = controllerHandlerTestObject.createResponse(HttpStatus.CHECKPOINT, "11", "Test");
assertEquals(HttpStatus.CHECKPOINT, responseEntity.getStatusCode());
assertEquals("{\"id\":11,\"message\":\"Test\"}", responseEntity.getBody());
}
use of com.blackducksoftware.integration.hub.alert.web.ObjectTransformer in project hub-alert by blackducksoftware.
the class ControllerHandlerTest method testCreateResponseWithLongID.
@Test
public void testCreateResponseWithLongID() {
final ObjectTransformer objectTransformer = new ObjectTransformer();
final ControllerHandlerTestObject controllerHandlerTestObject = new ControllerHandlerTestObject(objectTransformer);
final ResponseEntity<String> responseEntity = controllerHandlerTestObject.createResponse(HttpStatus.CHECKPOINT, 21L, "Test");
assertEquals(HttpStatus.CHECKPOINT, responseEntity.getStatusCode());
assertEquals("{\"id\":21,\"message\":\"Test\"}", responseEntity.getBody());
}
Aggregations