Calculator { private static int calcRate(int rankNo, long obfuscatedRate, int userRateFactor, boolean strict) { int rankRateFactor = RANK_RATE_FACTORS[rankNo % 13]; if (strict && obfuscatedRate % rankRateFactor != 0) { return NO_RATE; } else if (userRateFactor > 0) { if (strict && (obfuscatedRate / rankRateFactor) % userRateFactor != 0) { return NO_RATE; } return (int) (obfuscatedRate / rankRateFactor / userRateFactor - 91); } else { return NO_RATE; } }  static int calcRate(int rankNo, long obfuscatedRate, int userRateFactor); static long obfuscateRate(int rankNo, int rate, int userRateFactor); static int detectUserRateFactor(int rankNo, long obfuscatedRate, int actualRate); static int detectUserRateFactor(Map<Integer, Long> source); static final int NO_RATE; }
@Test @DisplayName("戦果を計算する") public void calcRateSuccess() { int rate = Calculator.calcRate(RANK_NO, OBF_RATE, USER_RATE_FACTOR); assertEquals(ACTUAL_RATE, rate); }
@Test @DisplayName("戦果係数が0のため戦果を求められない") public void calcRateFail() { int rate = Calculator.calcRate(RANK_NO, OBF_RATE, 0); assertEquals(Calculator.NO_RATE, rate); }