package com.redfin.validity;

import com.redfin.validity.FailedValidationExecutor;
import com.redfin.validity.ValidityUtils;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

final class VerifiableFactoryTest {

    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    // Test requirements
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    private static final String VALID_MESSAGE = "hello";
    private static final FailedValidationExecutor<IllegalArgumentException> VALIDATION_EXECUTOR = new FailedValidationExecutor<IllegalArgumentException>() {
        @Override
        public <T> void fail(String expected, T subject, String message) throws IllegalArgumentException {
            throw new IllegalArgumentException(expected + subject + message);
        }
    };

    private static final class TestVerifiableFactory extends VerifiableFactory<IllegalArgumentException> {
        private TestVerifiableFactory(String message, FailedValidationExecutor<IllegalArgumentException> failedValidationExecutor) {
            super(message, failedValidationExecutor);
        }
    }

    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    // Test cases
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    @Test
    void testCanInstantiateWithValidArguments() {
        Assertions.assertNotNull(new TestVerifiableFactory(VALID_MESSAGE, VALIDATION_EXECUTOR),
                                 "Should be able to instantiate a VerifiableFactory with valid arguments.");
    }

    @Test
    void testCanInstantiateWithNullMessage() {
        Assertions.assertNotNull(new TestVerifiableFactory(null, VALIDATION_EXECUTOR),
                                 "Should be able to instantiate a VerifiableFactory with a null message.");
    }

    @Test
    void testConstructorThrowsExceptionForNullValidationExecutor() {
        NullPointerException exception = Assertions.expectThrows(NullPointerException.class,
                                                                 () -> new TestVerifiableFactory(VALID_MESSAGE, null));
        Assertions.assertEquals(ValidityUtils.nullArgumentMessage("failedValidationExecutor"),
                                exception.getMessage(),
                                "Should not be able to instantiate a VerifiableFactory with a null failed validation executor.");
    }
}

@@ -1,93 +1,603 @@
-package com.redfin.validity;%0A%0Aimport com.redfin.validity.FailedValidationExecutor;%0Aimport
+/*%0A * Copyright: (c) 2016 Redfin%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A * http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Apackage
  com
@@ -616,23 +616,10 @@
 dity
-.ValidityUtils
 ;
+%0A
 %0Aimp

Add missing license comment