import "copyright.stg"
import "primitiveLiteral.stg"

isTest() ::= "true"

targetPath() ::= "org/eclipse/collections/impl/block/procedure/checked/primitive"

fileName(primitive) ::= "CheckedObject<primitive.name>ProcedureTest"

class(primitive) ::= <<
<body(primitive.type, primitive.name)>
>>

body(type, name) ::= <<
<copyright()>

package org.eclipse.collections.impl.block.procedure.checked.primitive;

import java.io.IOException;

import org.junit.Assert;
import org.junit.Test;

/**
 * Provides a set of common tests of checked procedures for Object and <type> values.
 * This file was automatically generated from template file checkedObjectPrimitiveProcedureTest.stg.
 *
 * @since 5.0.
 */
public final class CheckedObject<name>ProcedureTest
{
    @Test
    public void regular()
    {
        final boolean[] result = new boolean[1];
        new CheckedObject<name>Procedure\<Object>()
        {
            @Override
            public void safeValue(Object object, <type> item) throws Exception
            {
                result[0] = true;
            }
        }.value(null, <(zero.(type))>);
        Assert.assertTrue(result[0]);
    }

    @Test
    public void runtimeException()
    {
        Assert.assertThrows(RuntimeException.class, () -> {
            new CheckedObject<name>Procedure\<Object>()
            {
                @Override
                public void safeValue(Object object, <type> item) throws Exception
                {
                    throw new RuntimeException();
                }
            }.value(null, <(zero.(type))>);
        });
    }

    @Test
    public void checkedException()
    {
        Assert.assertThrows(RuntimeException.class, () -> {
            new CheckedObject<name>Procedure\<Object>()
            {
                @Override
                public void safeValue(Object object, <type> item) throws Exception
                {
                    throw new IOException();
                }
            }.value(null, <(zero.(type))>);
        });
    }
}

>>
