SafeguardLimitValidator { public void validate() { Long fiOffLimit = propertyHolder.getLong("safeguard.responseFIdecoder.OFFlimit"); Long fiOnLimit = propertyHolder.getLong("safeguard.responseFIdecoder.ONlimit"); Long mwOffLimit = propertyHolder.getLong("safeguard.responseMessageWriter.OFFlimit"); Long mwOnLimit = propertyHolder.getLong("safeguard.responseMessageWriter.ONlimit"); String jmxPort = propertyHolder.get("com.sun.management.jmxremote.port"); checkLimits(new SafeguardLimits(fiOffLimit, fiOnLimit, mwOffLimit, mwOnLimit, jmxPort)); }  void validate();  }
@Test(expectedExceptions = InvalidPropertyException.class) public void testValidateShouldThrowExceptionWhenFiOffLimitLessThanFiOnLimit() { given(getFiOffLimit()).willReturn(2L); given(getFiOnLimit()).willReturn(3L); given(getMwOffLimit()).willReturn(5L); given(getMwOnLimit()).willReturn(4L); underTest.validate(); }
@Test(expectedExceptions = InvalidPropertyException.class) public void testValidateShouldThrowExceptionWhenMwOnLimitLessThanFiOnLimit() { given(getFiOffLimit()).willReturn(4L); given(getFiOnLimit()).willReturn(3L); given(getMwOffLimit()).willReturn(5L); given(getMwOnLimit()).willReturn(2L); underTest.validate(); }
@Test(expectedExceptions = InvalidPropertyException.class) public void testValidateShouldThrowExceptionWhenMwOffLimitLessThanMwOnLimit() { given(getFiOffLimit()).willReturn(4L); given(getFiOnLimit()).willReturn(3L); given(getMwOffLimit()).willReturn(5L); given(getMwOnLimit()).willReturn(6L); underTest.validate(); }
@Test(expectedExceptions = InvalidPropertyException.class) public void testValidateShouldThrowExceptionWhenMwOffLimitLessThanFiOffLimit() { given(getFiOffLimit()).willReturn(4L); given(getFiOnLimit()).willReturn(3L); given(getMwOffLimit()).willReturn(3L); given(getMwOnLimit()).willReturn(5L); underTest.validate(); }
@Test(expectedExceptions = InvalidPropertyException.class) public void testValidateShouldThrowExceptionWhenLimitsAreNull() { given(getFiOffLimit()).willReturn(null); given(getFiOnLimit()).willReturn(null); given(getMwOffLimit()).willReturn(null); given(getMwOnLimit()).willReturn(null); underTest.validate(); }
@Test public void testValidateShouldNotThrowExceptionWhenAllLimitsAreValid() { given(getFiOffLimit()).willReturn(10L); given(getFiOnLimit()).willReturn(8L); given(getMwOffLimit()).willReturn(10L); given(getMwOnLimit()).willReturn(8L); underTest.validate(); }