Package helpers.badge

Source Code of helpers.badge.SpeakerBadgeComputerTest

package helpers.badge;

import java.util.EnumSet;
import models.Badge;
import models.LightningTalk;
import models.Member;
import models.Talk;
import org.junit.Test;

/**
* Unit tests for {@link SpeakerBadgeComputer}
* @author Sryl <cyril.lacote@gmail.com>
*/
public class SpeakerBadgeComputerTest extends AbstractBadgeComputerTest {

    public SpeakerBadgeComputerTest() {
        super(new SpeakerBadgeComputer());
    }

    private Talk createTalk(Member... speakers) {
        Talk t = new Talk();
        for (Member s : speakers) {
            t.addSpeaker(s);
        }
        return t.save();
    }

    private LightningTalk createLT(Member... speakers) {
        LightningTalk lt = new LightningTalk();
        for (Member s : speakers) {
            lt.addSpeaker(s);
        }
        return lt.save();
    }

    @Test
    public void grantedSpeaker() {
        // Member become speaker of a validated talk
        final Talk t = createTalk(member);
        assertEquals(EnumSet.noneOf(Badge.class), computer.compute(member, new BadgeComputationContext()));
        t.validate();
        assertEquals(EnumSet.of(Badge.Speaker), computer.compute(member, new BadgeComputationContext()));
    }

    @Test
    public void grantedSpeakerPadawan() {
        // Member become speaker of a LT
        final LightningTalk lt = createLT(member);
        assertEquals(EnumSet.of(Badge.SpeakerPadawan), computer.compute(member, new BadgeComputationContext()));
    }
}
TOP

Related Classes of helpers.badge.SpeakerBadgeComputerTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.