/*
 * Copyright 2018 Red Hat, Inc.
 *
 * 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.jboss.protean.arc.test.producer.primitive;

import static org.junit.Assert.assertEquals;

import javax.enterprise.context.Dependent;
import javax.enterprise.inject.Produces;

import org.jboss.protean.arc.Arc;
import org.jboss.protean.arc.test.ArcTestContainer;
import org.junit.Rule;
import org.junit.Test;

public class PrimitiveProducerTest {

    @Rule
    public ArcTestContainer container = new ArcTestContainer(IntProducer.class, LongProducer.class);

    @Test
    public void testPrimitiveProducers() {
        assertEquals(Long.valueOf(10), Arc.container().instance(Long.class).get());
        assertEquals(Integer.valueOf(10), Arc.container().instance(Integer.class).get());
    }

    @Dependent
    static class IntProducer {

        @Produces
        int foo = 10;

    }

    @Dependent
    static class LongProducer {

        @Produces
        long foo() {
            return 10;
        }

    }
}

@@ -776,16 +776,75 @@
 roduces;
+%0Aimport javax.inject.Inject;%0Aimport javax.inject.Singleton;
 %0A%0Aimport
@@ -1116,16 +1116,41 @@
 er.class
+, PrimitiveConsumer.class
 );%0A%0A    
@@ -1368,24 +1368,216 @@
 ss).get());%0A
+        PrimitiveConsumer consumer = Arc.container().instance(PrimitiveConsumer.class).get();%0A        assertEquals(10, consumer.getIntFoo());%0A        assertEquals(10l, consumer.getLongFoo());%0A
     %7D%0A%0A    @
@@ -1783,20 +1783,315 @@
 %0A        %7D%0A%0A
+    %7D%0A    %0A    @Singleton%0A    static class PrimitiveConsumer %7B%0A        %0A        @Inject%0A        int intFoo;%0A        %0A        @Inject%0A        long longFoo;%0A%0A        int getIntFoo() %7B%0A            return intFoo;%0A        %7D%0A%0A        long getLongFoo() %7B%0A            return longFoo;%0A        %7D%0A        %0A
     %7D%0A%7D%0A

Add simple test with primitives injection