All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.deephacks.tools4j.config.test.bean.BeanManagerCreateTests Maven / Gradle / Ivy

There is a newer version: 0.15.0
Show newest version
package org.deephacks.tools4j.config.test.bean;

import static org.deephacks.tools4j.config.test.JUnitUtils.generateBeans;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;

import java.util.List;

import org.deephacks.tools4j.config.model.Bean;
import org.deephacks.tools4j.config.model.Lookup;
import org.deephacks.tools4j.config.spi.BeanManager;
import org.deephacks.tools4j.config.test.FeatureTestsRunner;
import org.junit.Test;
import org.junit.runner.RunWith;

@RunWith(FeatureTestsRunner.class)
public class BeanManagerCreateTests {
    BeanManager manager = Lookup.get().lookup(BeanManager.class);

    @Test
    public void test_create_single() {
        List beans = generateBeans(2, 2);
        for (Bean b : beans) {
            manager.create(b);
        }

        for (Bean b : beans) {
            Bean r = manager.getEager(b.getId());
            assertThat(r, is(b));
        }
    }

    @Test
    public void test_create_all() {
        List beans = generateBeans(2, 2);
        manager.create(beans);
        for (Bean b : beans) {
            Bean r = manager.getEager(b.getId());
            assertThat(r, is(b));
        }
    }

    @Test
    public void test_create_default() {
        List beans = generateBeans(2, 2);
        for (Bean bean : beans) {
            bean.setDefault();
        }
        manager.create(beans);
        for (Bean b : beans) {
            Bean r = manager.getEager(b.getId());
            assertThat(r, is(b));
            assertThat(r.isDefault(), is(b.isDefault()));
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy