/** * Creates a (defensive) copy of itself. */ public Rankings copy() { return new Rankings(this); } }
/** * Creates a (defensive) copy of itself. */ public Rankings copy() { return new Rankings(this); } }
public AbstractRankerBolt(int topN, int emitFrequencyInSeconds) { if (topN < 1) { throw new IllegalArgumentException("topN must be >= 1 (you requested " + topN + ")"); } if (emitFrequencyInSeconds < 1) { throw new IllegalArgumentException( "The emit frequency must be >= 1 seconds (you requested " + emitFrequencyInSeconds + " seconds)"); } count = topN; this.emitFrequencyInSeconds = emitFrequencyInSeconds; rankings = new Rankings(count); }
public AbstractRankerBolt(int topN, int emitFrequencyInSeconds) { if (topN < 1) { throw new IllegalArgumentException("topN must be >= 1 (you requested " + topN + ")"); } if (emitFrequencyInSeconds < 1) { throw new IllegalArgumentException( "The emit frequency must be >= 1 seconds (you requested " + emitFrequencyInSeconds + " seconds)"); } count = topN; this.emitFrequencyInSeconds = emitFrequencyInSeconds; rankings = new Rankings(count); }
/** * Creates a (defensive) copy of itself. */ public Rankings copy() { return new Rankings(this); } }
public AbstractRankerBolt(int topN, int emitFrequencyInSeconds) { if (topN < 1) { throw new IllegalArgumentException("topN must be >= 1 (you requested " + topN + ")"); } if (emitFrequencyInSeconds < 1) { throw new IllegalArgumentException( "The emit frequency must be >= 1 seconds (you requested " + emitFrequencyInSeconds + " seconds)"); } count = topN; this.emitFrequencyInSeconds = emitFrequencyInSeconds; rankings = new Rankings(count); }
public class SingleFileProcessingTest { private static String[] fileRawData; @BeforeClass public static void fillRawData() { fileRawData = new String[2]; // values are from my head, resembling format from links you've posted fileRawData[0] = "Jacob\t20000\tEmily\t19999"; fileRawData[1] = "Michael\t18000\tMadison\t17000"; } @Test public void test() { Rankings rankings = new Rankings(); rankings.process(fileRawData); assertEquals("Jacob", rankings.getTop().getName()); assertEquals("Madison", rankings.getScorerOfPosition(4).getName()); assertEquals(18000, rankings.getScoreOf("Michael")); assertEquals(4, rankings.getSize()); } }
public class RankingsProcessingTest { @Test public void test() { Rankings rankings = new Rankings(); rankings.addScorer(new Scorer("Jacob", 20000)); rankings.addScorer(new Scorer("Emily", 19999)); rankings.addScorer(new Scorer("Michael", 18000)); rankings.addScorer(new Scorer("Madison", 17000)); assertEquals("Jacob", rankings.getTop().getName()); // assertEquals("Madison", rankings.getScorerOfPosition(4).getName()); // implementation of getScorerOfPosition(int) left as exercise :) assertEquals(18000, rankings.getScoreOf("Michael")); assertEquals(4, rankings.getSize()); } }