@Test public void testIsValidShouldReturnTrueWhenStatusIsUpdated() { UpdateStackJson updateStackJson = new UpdateStackJson(); updateStackJson.setInstanceGroupAdjustment(null); updateStackJson.setStatus(StatusRequest.STARTED); boolean valid = underTest.isValid(updateStackJson, constraintValidatorContext); assertTrue(valid); }
@Test public void testIsValidShouldReturnFalseWhenRequestContainsOnlyNulls() { UpdateStackJson updateStackJson = new UpdateStackJson(); updateStackJson.setInstanceGroupAdjustment(null); updateStackJson.setStatus(null); boolean valid = underTest.isValid(updateStackJson, constraintValidatorContext); assertFalse(valid); }
@Test public void testIsValidShouldReturnFalseWhenRequestContainsNodeCountAndStatus() { UpdateStackJson updateStackJson = new UpdateStackJson(); InstanceGroupAdjustmentJson instanceGroupAdjustmentJson = new InstanceGroupAdjustmentJson(); instanceGroupAdjustmentJson.setScalingAdjustment(4); instanceGroupAdjustmentJson.setInstanceGroup("slave_1"); updateStackJson.setStatus(StatusRequest.STARTED); updateStackJson.setInstanceGroupAdjustment(instanceGroupAdjustmentJson); boolean valid = underTest.isValid(updateStackJson, constraintValidatorContext); assertFalse(valid); }
@Test public void testIsValidShouldReturnTrueWhenNodeCountIsUpdated() { UpdateStackJson updateStackJson = new UpdateStackJson(); InstanceGroupAdjustmentJson instanceGroupAdjustmentJson = new InstanceGroupAdjustmentJson(); instanceGroupAdjustmentJson.setScalingAdjustment(12); instanceGroupAdjustmentJson.setInstanceGroup("slave_1"); updateStackJson.setInstanceGroupAdjustment(instanceGroupAdjustmentJson); updateStackJson.setStatus(null); boolean valid = underTest.isValid(updateStackJson, constraintValidatorContext); assertTrue(valid); }
@Test public void testInValidShouldReturnTrueWhenNodeCountIsLowerThanOneUpdatedAndWithClusterEvent() { UpdateStackJson updateStackJson = new UpdateStackJson(); InstanceGroupAdjustmentJson instanceGroupAdjustmentJson = new InstanceGroupAdjustmentJson(); instanceGroupAdjustmentJson.setScalingAdjustment(-1); instanceGroupAdjustmentJson.setWithClusterEvent(true); instanceGroupAdjustmentJson.setInstanceGroup("slave_1"); updateStackJson.setInstanceGroupAdjustment(instanceGroupAdjustmentJson); updateStackJson.setStatus(null); boolean valid = underTest.isValid(updateStackJson, constraintValidatorContext); assertFalse(valid); }