@@ -0,0 +1,2673 @@
+package org.lodder.subtools.multisubdownloader.lib.control.subtitles.sorting;%0A%0Aimport java.util.HashMap;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.lodder.subtools.sublibrary.model.Release;%0Aimport org.lodder.subtools.sublibrary.model.Subtitle;%0A%0A%0Aimport static org.junit.Assert.*;%0Aimport static org.mockito.Mockito.*;%0A%0Apublic class ScoreCalculatorTest %7B%0A%0A  protected ScoreCalculator calculator;%0A%0A  @Before%0A  public void setUp() throws Exception %7B%0A    calculator = null;%0A  %7D%0A%0A  @Test%0A  public void test_it_calculates_the_score_for_subtitle() throws Exception %7B%0A    SortWeight weights = createWeights();%0A%0A    calculator = new ScoreCalculator(weights);%0A    int score;%0A    Subtitle subtitle;%0A%0A    subtitle =%0A      createSubtitle(%22Arrested.Development.S01E01.DVDRip.XviD-MEDiEVAL.srt%22, %22dvdrip xvid%22, %22medieval%22);%0A    score = calculator.calculate(subtitle);%0A    assertEquals(convertToPercentage(8, weights), score);%0A%0A    subtitle =%0A      createSubtitle(%22Arrested Development 1x1 works with medieval.srt%22, %22%22, %22medieval%22);%0A    score = calculator.calculate(subtitle);%0A    assertEquals(convertToPercentage(5, weights), score);%0A%0A    subtitle =%0A      createSubtitle(%22Arrested.Development.S01E01.BDrip.XviD-Acme.srt%22, %22%22, %22acme%22);%0A    score = calculator.calculate(subtitle);%0A    assertEquals(convertToPercentage(1, weights), score);%0A%0A    subtitle =%0A      createSubtitle(%22Arrested.Development.S01E01.DVDRip.DivX-Acme.srt%22, %22%22, %22acme%22);%0A    score = calculator.calculate(subtitle);%0A    assertEquals(convertToPercentage(2, weights), score);%0A%0A    subtitle =%0A      createSubtitle(%22Arrested.Development.S01E01.BluRay.x264-OSCORP.srt%22, %22%22, %22oscorp%22);%0A    score = calculator.calculate(subtitle);%0A    assertEquals(convertToPercentage(0, weights), score);%0A  %7D%0A%0A  private int convertToPercentage(int score, SortWeight weights)%7B%0A    return (score / weights.getMaxScore()) * 100;%0A  %7D%0A%0A  private Subtitle createSubtitle(String filename, String quality, String team) %7B%0A    Subtitle subtitle = mock(Subtitle.class);%0A    when(subtitle.getFilename()).thenReturn(filename);%0A    when(subtitle.getQuality()).thenReturn(quality);%0A    when(subtitle.getTeam()).thenReturn(team);%0A    return subtitle;%0A  %7D%0A%0A  private SortWeight createWeights() %7B%0A    // Arrested.Development.S01E01.DVDRip.XviD-MEDiEVAL%0A    Release release = mock(Release.class);%0A    when(release.getQuality()).thenReturn(%22DVDRip XviD%22);%0A    when(release.getReleasegroup()).thenReturn(%22MEDiEVAL%22);%0A%0A    HashMap%3CString, Integer%3E definedWeights = new HashMap%3C%3E();%0A    definedWeights.put(%22dvdrip%22, 2);%0A    definedWeights.put(%22xvid%22, 1);%0A    definedWeights.put(%22%25GROUP%25%22, 5);%0A%0A    return new SortWeight(release, definedWeights);%0A  %7D%0A%7D%0A

Create test for ScoreCalculator