package org.jtheque.errors;

import org.jtheque.errors.Error.Level;

import org.junit.Test;

import static org.junit.Assert.assertEquals;

/*
 * Copyright JTheque (Baptiste Wicht)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

public class ErrorsTest {
    @Test
    public void title(){
        Error error = Errors.newError("Title 1");

        assertEquals("Title 1", error.getTitle(null));
        assertEquals(Level.ERROR, error.getLevel());
    }

    @Test
    public void titleLevel() {
        Error error = Errors.newError("Title 2", Level.WARNING);

        assertEquals("Title 2", error.getTitle(null));
        assertEquals(Level.WARNING, error.getLevel());
    }

    @Test
    public void titleDetails() {
        Error error = Errors.newError("Title 3", "Details 3");

        assertEquals("Title 3", error.getTitle(null));
        assertEquals("Details 3", error.getDetails(null));
        assertEquals(Level.ERROR, error.getLevel());
    }
}
@@ -1462,10 +1462,597 @@
 );%0A    %7D
+%0A%0A    @Test%0A    public void throwable() %7B%0A        Throwable throwable = new RuntimeException(%22Simple message%22);%0A%0A        Error error = Errors.newError(throwable);%0A%0A        assertEquals(%22Simple message%22, error.getTitle(null));%0A        assertEquals(Level.ERROR, error.getLevel());%0A    %7D%0A%0A    @Test%0A    public void throwableTitle() %7B%0A        Throwable throwable = new RuntimeException(%22Simple message%22);%0A%0A        Error error = Errors.newError(%22Simple title%22, throwable);%0A%0A        assertEquals(%22Simple title%22, error.getTitle(null));%0A        assertEquals(Level.ERROR, error.getLevel());%0A    %7D
 %0A%7D

Test constructors with Throwable