public String check( Naked[] values) { final Consent usable = getOneToOneAssociationInstance().getOneToOneAssociation().isUsable(); return usable.isAllowed()?null:usable.getReason(); }
public String check( Naked[] values) { OneToOneAssociationInstance otoai = getOneToOneAssociationInstance(); final Consent usable = otoai.getOneToOneAssociation().isUsable(otoai.getNakedObject()); return usable.isAllowed()?null:usable.getReason(); }
public void testSetAssociation() { // the field must be authorised and available associationControl.expectAndReturn(association.getId(), "director"); associationControl.expectAndReturn(association.isVisible(), true); associationControl.expectAndReturn(association.isUsable(movieAdapter), Allow.DEFAULT); // after checking association is asked to do setting association.setAssociation(movieAdapter, directorAdapter); replay(); ObjectData[] updates = server.setAssociation(session, "director", movieData, personData); verify(); assertEquals(0, updates.length); }
public void testSetAssociationFailsWhenUnavailable() { associationControl.expectAndReturn(association.getId(), "director"); // the field is authorised, but not available associationControl.expectAndReturn(association.isVisible(), true); associationControl.expectAndReturn(association.isUsable(movieAdapter), Veto.DEFAULT); replay(); try { server.setAssociation(session, "director", movieData, personData); fail(); } catch (IllegalRequestException expected) { assertEquals("can't modify field as not visible or editable", expected.getMessage()); } verify(); }
public void testClearAssociation() { /* * other tests for clear: * - clear collection element * - fails if unauthorised * - fails if unavailable * * could place all these clear test in one class; test other methods in other classes */ // the field must be authorised and available associationControl.expectAndReturn(association.getId(), "director"); associationControl.expectAndReturn(association.isVisible(), true); associationControl.expectAndReturn(association.isUsable(movieAdapter), Allow.DEFAULT); // after checking association is asked to do clearing association.clearAssociation(movieAdapter, directorAdapter); replay(); ObjectData[] updatesData = server.clearAssociation(session, "director", movieData, personData); verify(); assertEquals(0, updatesData.length); }