@Test public void test_delete_reference_violation() { admin.createObjects(Arrays.asList(g1, g2, p1, p2, c1, c2)); // test single try { admin.delete(BeanId.create("c1", ConfigTestData.CHILD_SCHEMA_NAME)); fail("Should not be possible to delete a bean with references"); } catch (AbortRuntimeException e) { assertThat(e.getEvent().getCode(), is(CFG302)); } // test multiple try { admin.delete(ConfigTestData.CHILD_SCHEMA_NAME, Arrays.asList("c1", "c2")); fail("Should not be possible to delete a bean with references"); } catch (AbortRuntimeException e) { assertThat(e.getEvent().getCode(), is(CFG302)); } }
@Test public void test_set_merge_without_schema() { Bean b = Bean.create(BeanId.create("1", "missing_schema_name")); try { admin.create(b); fail("Cant add beans without a schema."); } catch (AbortRuntimeException e) { assertThat(e.getEvent().getCode(), is(CFG101)); assertThat(observer.getChanges().size(), is(0)); } try { admin.merge(b); fail("Cant add beans without a schema."); } catch (AbortRuntimeException e) { assertThat(e.getEvent().getCode(), is(CFG101)); assertThat(observer.getChanges().size(), is(0)); } }
@Test public void test_set_merge_without_schema() { Bean b = Bean.create(BeanId.create("1", "missing_schema_name")); try { admin.create(b); fail("Cant add beans without a schema."); } catch (AbortRuntimeException e) { assertThat(e.getEvent().getCode(), is(CFG101)); } try { admin.merge(b); fail("Cant add beans without a schema."); } catch (AbortRuntimeException e) { assertThat(e.getEvent().getCode(), is(CFG101)); } }
@Test public void test_delete_reference_violation() { admin.create(toBeans(g1, g2, p1, p2, c1, c2)); observer.clear(); // test single try { admin.delete(BeanId.create("c1", CHILD_SCHEMA_NAME)); fail("Should not be possible to delete a bean with references"); } catch (AbortRuntimeException e) { assertThat(e.getEvent().getCode(), is(CFG302)); assertThat(observer.getChanges().size(), is(0)); } // test multiple try { admin.delete(CHILD_SCHEMA_NAME, Arrays.asList("c1", "c2")); fail("Should not be possible to delete a bean with references"); } catch (AbortRuntimeException e) { assertThat(e.getEvent().getCode(), is(CFG302)); assertThat(observer.getChanges().size(), is(0)); } }
@Override public void registerDefault(Object... instances) { doLookup(); for (Object instance : instances) { Bean bean = conversion.convert(instance, Bean.class); bean.setDefault(); try { beanManager.create(bean); } catch (AbortRuntimeException e) { // ignore if bean already exist if (e.getEvent().getCode() != CFG303) { throw e; } } } }
@Test public void test_remove_schema() { Set<Schema> schemas = generateSchemas(2, 2); for (Schema schema : schemas) { manager.registerSchema(schema); Schema response = manager.getSchema(schema.getName()); assertThat(schema, equalTo(response)); } Schema s = schemas.iterator().next(); assertThat(manager.getSchema(s.getName()), is(s)); manager.removeSchema(s.getName()); try { s = manager.getSchema(s.getName()); } catch (AbortRuntimeException e) { assertThat(e.getEvent().getCode(), is(Events.CFG101)); } }
@Test public void test_delete_default() { List<Bean> 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)); } } } }
fail("Not possible to set property names that does not exist in schema"); } catch (AbortRuntimeException e) { assertThat(e.getEvent().getCode(), is(CFG110)); assertThat(observer.getChanges().size(), is(0)); fail("Not possible to set property names that does not exist in schema"); } catch (AbortRuntimeException e) { assertThat(e.getEvent().getCode(), is(CFG110)); assertThat(observer.getChanges().size(), is(0)); fail("Not possible to set property names that does not exist in schema"); } catch (AbortRuntimeException e) { assertThat(e.getEvent().getCode(), is(CFG110)); assertThat(observer.getChanges().size(), is(0)); fail("Not possible to set property names that does not exist in schema"); } catch (AbortRuntimeException e) { assertThat(e.getEvent().getCode(), is(CFG111)); assertThat(observer.getChanges().size(), is(0)); fail("Not possible to set property names that does not exist in schema"); } catch (AbortRuntimeException e) { assertThat(e.getEvent().getCode(), is(CFG110)); assertThat(observer.getChanges().size(), is(0)); fail("Not possible to set property names that does not exist in schema"); } catch (AbortRuntimeException e) { assertThat(e.getEvent().getCode(), is(CFG110)); assertThat(observer.getChanges().size(), is(0));
fail("Should not be possible to merge invalid reference"); } catch (AbortRuntimeException e) { if (e.getEvent().getCode() != CFG301 && e.getEvent().getCode() != CFG304) { fail("Should not be possible to merge invalid reference"); assertThat(observer.getChanges().size(), is(0)); } catch (AbortRuntimeException e) { if (e.getEvent().getCode() != CFG301 && e.getEvent().getCode() != CFG304) { fail("Should not be possible to merge invalid reference"); fail("Should not be possible to merge beans that does not exist"); } catch (AbortRuntimeException e) { if (e.getEvent().getCode() != CFG301 && e.getEvent().getCode() != CFG304) { fail("Should not be possible to merge invalid reference"); fail("Should not be possible to merge invalid reference"); } catch (AbortRuntimeException e) { if (e.getEvent().getCode() != CFG301 && e.getEvent().getCode() != CFG304) { fail("Should not be possible to merge invalid reference");
fail("Not possible to set property names that does not exist in schema"); } catch (AbortRuntimeException e) { assertThat(e.getEvent().getCode(), is(CFG110)); fail("Not possible to set property names that does not exist in schema"); } catch (AbortRuntimeException e) { assertThat(e.getEvent().getCode(), is(CFG110)); fail("Not possible to set property names that does not exist in schema"); } catch (AbortRuntimeException e) { assertThat(e.getEvent().getCode(), is(CFG110)); fail("Not possible to set property names that does not exist in schema"); } catch (AbortRuntimeException e) { assertThat(e.getEvent().getCode(), is(CFG111)); fail("Not possible to set property names that does not exist in schema"); } catch (AbortRuntimeException e) { assertThat(e.getEvent().getCode(), is(CFG110)); fail("Not possible to set property names that does not exist in schema"); } catch (AbortRuntimeException e) { assertThat(e.getEvent().getCode(), is(CFG110));
fail("10000 does not fit java.lang.Byte"); } catch (AbortRuntimeException e) { assertThat(e.getEvent().getCode(), is(CFG105)); assertThat(observer.getChanges().size(), is(0)); fail("2.2 does not fit a collection of java.lang.Integer"); } catch (AbortRuntimeException e) { assertThat(e.getEvent().getCode(), is(CFG105)); assertThat(observer.getChanges().size(), is(0)); fail("not_a_enum is not a value of TimeUnit"); } catch (AbortRuntimeException e) { assertThat(e.getEvent().getCode(), is(CFG105)); assertThat(observer.getChanges().size(), is(0)); fail("not_a_enum is not a value of TimeUnit"); } catch (AbortRuntimeException e) { assertThat(e.getEvent().getCode(), is(CFG105)); assertThat(observer.getChanges().size(), is(0)); fail("Cannot add mutiple values to a single valued property."); } catch (AbortRuntimeException e) { assertThat(e.getEvent().getCode(), is(CFG106)); assertThat(observer.getChanges().size(), is(0)); fail("Cannot add a value to a single typed value."); } catch (AbortRuntimeException e) { assertThat(e.getEvent().getCode(), is(CFG105)); assertThat(observer.getChanges().size(), is(0));
fail("10000 does not fit java.lang.Byte"); } catch (AbortRuntimeException e) { assertThat(e.getEvent().getCode(), is(CFG105)); fail("2.2 does not fit a collection of java.lang.Integer"); } catch (AbortRuntimeException e) { assertThat(e.getEvent().getCode(), is(CFG105)); fail("not_a_enum is not a value of TimeUnit"); } catch (AbortRuntimeException e) { assertThat(e.getEvent().getCode(), is(CFG105)); fail("not_a_enum is not a value of TimeUnit"); } catch (AbortRuntimeException e) { assertThat(e.getEvent().getCode(), is(CFG105)); fail("Cannot add mutiple values to a single valued property."); } catch (AbortRuntimeException e) { assertThat(e.getEvent().getCode(), is(CFG106)); fail("Cannot add a value to a single typed value."); } catch (AbortRuntimeException e) { assertThat(e.getEvent().getCode(), is(CFG105));
fail("Area exceeds constraint"); } catch (AbortRuntimeException e) { assertThat(e.getEvent().getCode(), is(CFG309)); fail("Prop does not have first upper case."); } catch (AbortRuntimeException e) { assertThat(e.getEvent().getCode(), is(CFG309)); fail("Prop must be longer than one char"); } catch (AbortRuntimeException e) { assertThat(e.getEvent().getCode(), is(CFG309)); fail("Width and height may not be null."); } catch (AbortRuntimeException e) { assertThat(e.getEvent().getCode(), is(CFG309));
fail("Area exceeds constraint"); } catch (AbortRuntimeException e) { assertThat(e.getEvent().getCode(), is(CFG309)); fail("Prop does not have first upper case."); } catch (AbortRuntimeException e) { assertThat(e.getEvent().getCode(), is(CFG309)); fail("Prop must be longer than one char"); } catch (AbortRuntimeException e) { assertThat(e.getEvent().getCode(), is(CFG309)); fail("Width and height may not be null."); } catch (AbortRuntimeException e) { assertThat(e.getEvent().getCode(), is(CFG309));
fail("Should not be possible to merge invalid reference"); } catch (AbortRuntimeException e) { if (e.getEvent().getCode() != CFG301) { fail("Should not be possible to merge invalid reference"); fail("Should not be possible to merge invalid reference"); } catch (AbortRuntimeException e) { if (e.getEvent().getCode() != CFG301) { fail("Should not be possible to merge invalid reference"); fail("Should not be possible to merge beans that does not exist"); } catch (AbortRuntimeException e) { if (e.getEvent().getCode() != CFG301) { fail("Should not be possible to merge invalid reference"); fail("Should not be possible to merge invalid reference"); } catch (AbortRuntimeException e) { if (e.getEvent().getCode() != CFG301) { fail("Should not be possible to merge invalid reference");