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

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

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

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

import java.util.List;

import static org.deephacks.tools4j.config.model.Events.CFG311;
import static org.deephacks.tools4j.config.test.JUnitUtils.generateBeans;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;

@RunWith(FeatureTestsRunner.class)
public class BeanManagerDeleteTests {
    BeanManager manager = LookupProxy.lookup(BeanManager.class);

    @Before
    public void before() {

    }

    @Test
    public void test_delete_default() {
        List beans = generateBeans(2, 2);
        for (Bean bean : beans) {
            bean.setDefault();
        }
        manager.create(beans);
        for (Bean bean : beans) {
            try {
                manager.delete(bean.getId());
                fail("Should not be able to delete default instances");
            } catch (AbortRuntimeException e) {
                assertThat(e.getEvent().getCode(), is(CFG311));
            }
        }

    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy