/*
 *
 * Copyright (c) 2006-2019, Speedment, Inc. All Rights Reserved.
 *
 * 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.
 */

package com.speedment.runtime.compute.expression.orelse;

import static org.junit.jupiter.api.Assertions.assertEquals;

import com.speedment.runtime.compute.ToEnumNullable;
import org.junit.jupiter.api.Test;

final class ToEnumOrThrowTest {

    @Test
    void nullStrategy() {
        assertEquals(TestEnum.class, new DummyToEnumOrThrowTest().enumClass());
    }

    private static final class DummyToEnumOrThrowTest implements ToEnumOrThrow<Integer, TestEnum> {

        @Override
        public Class<TestEnum> enumClass() {
            return TestEnum.class;
        }

        @Override
        public TestEnum apply(Integer integer) {
            return null;
        }

        @Override
        public ToEnumNullable<Integer, TestEnum> innerNullable() {
            return null;
        }
    }

    private enum TestEnum {

    }
}

@@ -742,16 +742,78 @@
 tEquals;
+%0Aimport static org.junit.jupiter.api.Assertions.assertNotNull;
 %0A%0Aimport
@@ -951,20 +951,17 @@
 oid 
+e
 nu
-llStrategy
+mClass
 () %7B
@@ -973,297 +973,102 @@
     
-assertEquals(TestEnum.class, new DummyToEnumOrThrowTest().enumClass());%0A    %7D%0A%0A    private static final class DummyToEnumOrThrowTest implements ToEnumOrThrow%3CInteger, TestEnum%3E %7B%0A%0A        @Override%0A        public Class%3CTestEnum%3E enumClass() %7B%0A            return TestEnum.class;%0A        %7D%0A%0A
+ToEnumOrThrow%3CInteger, TestEnum%3E toEnumOrThrow = new ToEnumOrThrow%3CInteger, TestEnum%3E() %7B%0A    
     
@@ -1073,32 +1073,36 @@
       @Override%0A
+    
         public T
@@ -1138,32 +1138,36 @@
 ) %7B%0A            
+    
 return null;%0A   
@@ -1155,32 +1155,36 @@
    return null;%0A
+    
         %7D%0A%0A     
@@ -1178,32 +1178,36 @@
      %7D%0A%0A        
+    
 @Override%0A      
@@ -1192,32 +1192,36 @@
       @Override%0A
+    
         public T
@@ -1287,30 +1287,217 @@
     
+    
 return 
-null;%0A        %7D
+ToEnumNullable.of(TestEnum.class, integer -%3E TestEnum.A);%0A            %7D%0A        %7D;%0A%0A        assertNotNull(toEnumOrThrow.enumClass());%0A        assertEquals(TestEnum.class, toEnumOrThrow.enumClass());
 %0A   
@@ -1528,16 +1528,25 @@
 tEnum %7B%0A
+        A
 %0A    %7D%0A%7D

refactor ToEnumOrThrow test