/*
 * Copyright 2015 Red Hat, Inc. and/or its affiliates.
 *
 * 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 org.optaplanner.core.config.util;

import org.junit.Test;

import static org.junit.Assert.*;
import static org.optaplanner.core.config.util.ConfigUtils.*;

public class ConfigUtilsTest {

    @Test
    public void testMergeProperty() {
        Integer a = null;
        Integer b = null;
        assertEquals(null, mergeProperty(a, b));
        a = Integer.valueOf(1);
        assertEquals(null, mergeProperty(a, b));
        b = Integer.valueOf(10);
        assertEquals(null, mergeProperty(a, b));
        b = Integer.valueOf(1);
        assertEquals(Integer.valueOf(1), mergeProperty(a, b));
        a = null;
        assertEquals(null, mergeProperty(a, b));
    }

    @Test
    public void testMeldProperty() {
        Integer a = null;
        Integer b = null;
        assertEquals(null, meldProperty(a, b));
        a = Integer.valueOf(1);
        assertEquals(Integer.valueOf(1), meldProperty(a, b));
        b = Integer.valueOf(10);
        assertEquals(mergeProperty(Integer.valueOf(1), Integer.valueOf(10)), meldProperty(a, b));
        a = null;
        assertEquals(Integer.valueOf(10), meldProperty(a, b));
    }

    @Test
    public void testCeilDivide() {
        assertEquals(10, ceilDivide(19, 2));
        assertEquals(10, ceilDivide(20, 2));
        assertEquals(11, ceilDivide(21, 2));

        assertEquals(-9, ceilDivide(19, -2));
        assertEquals(-10, ceilDivide(20, -2));
        assertEquals(-10, ceilDivide(21, -2));

        assertEquals(-9, ceilDivide(-19, 2));
        assertEquals(-10, ceilDivide(-20, 2));
        assertEquals(-10, ceilDivide(-21, 2));

        assertEquals(10, ceilDivide(-19, -2));
        assertEquals(10, ceilDivide(-20, -2));
        assertEquals(11, ceilDivide(-21, -2));
    }

    @Test(expected = ArithmeticException.class)
    public void testCeilDivideByZero() {
        ceilDivide(20, -0);
    }

}

@@ -720,70 +720,8 @@
 t.*;
-%0Aimport static org.optaplanner.core.config.util.ConfigUtils.*;
 %0A%0Apu
@@ -776,21 +776,17 @@
 ic void 
-testM
+m
 ergeProp
@@ -865,32 +865,44 @@
 ertEquals(null, 
+ConfigUtils.
 mergeProperty(a,
@@ -958,32 +958,44 @@
 ertEquals(null, 
+ConfigUtils.
 mergeProperty(a,
@@ -1052,32 +1052,44 @@
 ertEquals(null, 
+ConfigUtils.
 mergeProperty(a,
@@ -1167,16 +1167,28 @@
 eOf(1), 
+ConfigUtils.
 mergePro
@@ -1246,16 +1246,28 @@
 s(null, 
+ConfigUtils.
 mergePro
@@ -1317,13 +1317,9 @@
 oid 
-testM
+m
 eldP
@@ -1409,16 +1409,28 @@
 s(null, 
+ConfigUtils.
 meldProp
@@ -1515,16 +1515,28 @@
 eOf(1), 
+ConfigUtils.
 meldProp
@@ -1602,16 +1602,28 @@
 tEquals(
+ConfigUtils.
 mergePro
@@ -1670,16 +1670,28 @@
 f(10)), 
+ConfigUtils.
 meldProp
@@ -1763,16 +1763,28 @@
 Of(10), 
+ConfigUtils.
 meldProp
@@ -1821,37 +1821,33 @@
     public void 
-testC
+c
 eilDivide() %7B%0A  
@@ -1861,32 +1861,44 @@
 ssertEquals(10, 
+ConfigUtils.
 ceilDivide(19, 2
@@ -1918,32 +1918,44 @@
 ssertEquals(10, 
+ConfigUtils.
 ceilDivide(20, 2
@@ -1975,32 +1975,44 @@
 ssertEquals(11, 
+ConfigUtils.
 ceilDivide(21, 2
@@ -2033,32 +2033,44 @@
 ssertEquals(-9, 
+ConfigUtils.
 ceilDivide(19, -
@@ -2092,32 +2092,44 @@
 sertEquals(-10, 
+ConfigUtils.
 ceilDivide(20, -
@@ -2151,32 +2151,44 @@
 sertEquals(-10, 
+ConfigUtils.
 ceilDivide(21, -
@@ -2218,16 +2218,28 @@
 als(-9, 
+ConfigUtils.
 ceilDivi
@@ -2269,32 +2269,44 @@
 sertEquals(-10, 
+ConfigUtils.
 ceilDivide(-20, 
@@ -2332,24 +2332,36 @@
 Equals(-10, 
+ConfigUtils.
 ceilDivide(-
@@ -2387,32 +2387,44 @@
 ssertEquals(10, 
+ConfigUtils.
 ceilDivide(-19, 
@@ -2454,16 +2454,28 @@
 als(10, 
+ConfigUtils.
 ceilDivi
@@ -2513,16 +2513,28 @@
 als(11, 
+ConfigUtils.
 ceilDivi
@@ -2622,13 +2622,9 @@
 oid 
-testC
+c
 eilD
@@ -2647,16 +2647,28 @@
         
+ConfigUtils.
 ceilDivi

remove "test" prefix