
package com.soulwarelabs.ecmabox.api.log;

import java.util.Arrays;
import java.util.List;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

import org.powermock.modules.junit4.PowerMockRunner;

import com.soulwarelabs.ecmabox.test.convention.UnitTest;

@UnitTest(RecordLevel.class)
@RunWith(PowerMockRunner.class)
public class RecordLevelTest {

    private List<RecordLevel> elements;

    @Before
    public void prepareElements() {
        elements = Arrays.asList(
                RecordLevel.TRACE,
                RecordLevel.DEBUG,
                RecordLevel.INFO,
                RecordLevel.WARN,
                RecordLevel.ERROR,
                RecordLevel.FATAL
        );
    }

    @Test
    public void doesNotContainExtraElements() throws Exception {
        Assert.assertEquals(elements.size(), RecordLevel.values().length);
    }

    @Test
    public void precedencesAreInOrder() throws Exception {
        RecordLevel previous = null;
        for (final RecordLevel level : elements) {
            if (previous != null) {
                Assert.assertTrue(previous.lowerThan(level));
            }
            previous = level;
        }
    }
}
