@Test public void testDeleteAssignment() { final EntityKind entityKind = EntityKind.EXPERIMENT; final ExperimentTypePE experimentType = createExperimentType(); final PropertyTypePE propertyType = createPropertyType(); final ExperimentTypePropertyTypePE etpt = new ExperimentTypePropertyTypePE(); prepareExperimentTypeAndPropertyType(entityKind, experimentType, propertyType); context.checking( new Expectations() { { one(entityPropertyTypeDAO).tryFindAssignment(experimentType, propertyType); will(returnValue(etpt)); one(entityPropertyTypeDAO).delete(etpt); } }); IEntityTypePropertyTypeBO bo = createEntityTypePropertyTypeBO(entityKind); bo.loadAssignment(propertyType.getCode(), experimentType.getCode()); bo.deleteLoadedAssignment(); try { bo.getLoadedAssignment(); fail("IllegalStateException expected."); } catch (IllegalStateException e) { assertEquals("No assignment loaded.", e.getMessage()); } context.assertIsSatisfied(); }
@Test public void testLoadAssignment() { final EntityKind entityKind = EntityKind.EXPERIMENT; final ExperimentTypePE experimentType = createExperimentType(); final PropertyTypePE propertyType = createPropertyType(); final ExperimentTypePropertyTypePE etpt = new ExperimentTypePropertyTypePE(); prepareExperimentTypeAndPropertyType(entityKind, experimentType, propertyType); context.checking( new Expectations() { { one(entityPropertyTypeDAO).tryFindAssignment(experimentType, propertyType); will(returnValue(etpt)); } }); IEntityTypePropertyTypeBO bo = createEntityTypePropertyTypeBO(entityKind); bo.loadAssignment(propertyType.getCode(), experimentType.getCode()); assertSame(etpt, bo.getLoadedAssignment()); context.assertIsSatisfied(); }