Search in sources :

Example 1 with ScScore

use of com.faendir.zachtronics.bot.sc.model.ScScore in project zachtronics-leaderboard-bot by F43nd1r.

the class SolRepoSubmitTest method testSubmitData.

@Test
public void testSubmitData() {
    // we start at 100/100/100
    ScScore score = new ScScore(50, 50, 50, false, false);
    // 50/50/50
    assertInstanceOf(SubmitResult.Success.class, doSubmitScore(score));
    String data = "SOLUTION:A Most Unfortunate Malfunction,12345ieee,45-1-14\nbunch of stuff...";
    // 45/1/14
    assertInstanceOf(SubmitResult.Success.class, doSubmitData(data));
    // identical
    assertInstanceOf(SubmitResult.AlreadyPresent.class, doSubmitData(data));
    data = "SOLUTION:A Most Unfortunate Malfunction,12345ieee,45-1-14\ndifferent stuff...";
    // changed data, I can
    assertInstanceOf(SubmitResult.Success.class, doSubmitData(data));
    data = "SOLUTION:A Most Unfortunate Malfunction,BadGuy,45-1-14\ndifferent stuff...";
    // stealing is bad
    assertInstanceOf(SubmitResult.AlreadyPresent.class, doSubmitData(data));
    data = "SOLUTION:A Most Unfortunate Malfunction,BadGuy,50-1-50\nsome more stuff...";
    // just give up, man
    assertInstanceOf(SubmitResult.NothingBeaten.class, doSubmitData(data));
}
Also used : ScScore(com.faendir.zachtronics.bot.sc.model.ScScore) SubmitResult(com.faendir.zachtronics.bot.repository.SubmitResult) Test(org.junit.jupiter.api.Test) BotTest(com.faendir.zachtronics.bot.BotTest)

Example 2 with ScScore

use of com.faendir.zachtronics.bot.sc.model.ScScore in project zachtronics-leaderboard-bot by F43nd1r.

the class ScSolution method unmarshal.

@NotNull
public static ScSolution unmarshal(@NotNull String[] fields) {
    assert fields.length == 5;
    ScScore score = Objects.requireNonNull(ScScore.parseScore(fields[0]));
    String author = fields[1];
    String displayLink = fields[2];
    boolean videoOnly = fields[3] != null;
    String categories = fields[4];
    ScSolution solution = new ScSolution(score, author, displayLink, videoOnly);
    if (categories != null)
        Pattern.compile(",").splitAsStream(categories).map(ScCategory::valueOf).forEach(solution.categories::add);
    return solution;
}
Also used : ScScore(com.faendir.zachtronics.bot.sc.model.ScScore) ScCategory(com.faendir.zachtronics.bot.sc.model.ScCategory) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with ScScore

use of com.faendir.zachtronics.bot.sc.model.ScScore in project zachtronics-leaderboard-bot by F43nd1r.

the class SolRepoSubmitTest method testSubmitScore.

@Test
public void testSubmitScore() {
    // we start with a 100/100/100
    ScScore score = new ScScore(100, 100, 100, true, true);
    // our score is a BP, fail
    assertInstanceOf(SubmitResult.NothingBeaten.class, doSubmitScore(score));
    score = new ScScore(100, 100, 100, false, true);
    // our score is a P, fail
    assertInstanceOf(SubmitResult.NothingBeaten.class, doSubmitScore(score));
    score = new ScScore(100, 100, 100, false, false);
    // identical score, different content, accept
    assertInstanceOf(SubmitResult.Success.class, doSubmitScore(score));
    score = new ScScore(10, 100, 1000, true, true);
    // new frontier piece
    assertInstanceOf(SubmitResult.Success.class, doSubmitScore(score));
    score = new ScScore(1000, 100, 10, true, true);
    // new frontier piece
    assertInstanceOf(SubmitResult.Success.class, doSubmitScore(score));
    score = new ScScore(10, 10, 10, true, true);
    // beats them both
    assertInstanceOf(SubmitResult.Success.class, doSubmitScore(score));
    score = new ScScore(20, 20, 20, true, true);
    // falls flat
    assertInstanceOf(SubmitResult.NothingBeaten.class, doSubmitScore(score));
    score = new ScScore(20, 20, 20, false, true);
    // new non bugged record
    assertInstanceOf(SubmitResult.Success.class, doSubmitScore(score));
}
Also used : ScScore(com.faendir.zachtronics.bot.sc.model.ScScore) SubmitResult(com.faendir.zachtronics.bot.repository.SubmitResult) Test(org.junit.jupiter.api.Test) BotTest(com.faendir.zachtronics.bot.BotTest)

Aggregations

ScScore (com.faendir.zachtronics.bot.sc.model.ScScore)3 BotTest (com.faendir.zachtronics.bot.BotTest)2 SubmitResult (com.faendir.zachtronics.bot.repository.SubmitResult)2 Test (org.junit.jupiter.api.Test)2 ScCategory (com.faendir.zachtronics.bot.sc.model.ScCategory)1 NotNull (org.jetbrains.annotations.NotNull)1