DesiredPitchRollCalculator { public int getValue(int value) { int absolute = getAbsolute(value); int calculatedValue = map(absolute, MIN_LIMIT, MAX_LIMIT, MIN_LIMIT, MAX_LIMIT - limit); if (value > MID) { return MID + calculatedValue; } else { return MID - calculatedValue; } } DesiredPitchRollCalculator(int limit); void setLimit(int limit); int getValue(int value); int getAbsolute(int value); static final int MID; static final int MIN_LIMIT; static final int MAX_LIMIT; }
@Test public void shouldReturn1500For1500Value() { assertThat(calculator.getValue(1500)).isEqualTo(1500); }
@Test public void shouldReturn1000For1000Value_ifNothingIsSet() { assertThat(calculator.getValue(1000)).isEqualTo(1000); }