You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2011/05/03 09:53:11 UTC
svn commit: r1098951 [2/11] - in /incubator/isis/trunk/viewer:
junit/src/main/java/org/apache/isis/viewer/junit/
junit/src/main/java/org/apache/isis/viewer/junit/internal/
junit/src/test/java/org/apache/isis/viewer/junit/
junit/src/test/java/org/apache...
Modified: incubator/isis/trunk/viewer/junit/src/test/java/org/apache/isis/viewer/junit/MemberHiddenTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/junit/src/test/java/org/apache/isis/viewer/junit/MemberHiddenTest.java?rev=1098951&r1=1098950&r2=1098951&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/junit/src/test/java/org/apache/isis/viewer/junit/MemberHiddenTest.java (original)
+++ incubator/isis/trunk/viewer/junit/src/test/java/org/apache/isis/viewer/junit/MemberHiddenTest.java Tue May 3 07:53:06 2011
@@ -17,9 +17,8 @@
* under the License.
*/
+package org.apache.isis.viewer.junit;
-package org.apache.isis.viewer.junit;
-
import static org.apache.isis.core.commons.matchers.IsisMatchers.classEqualTo;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
@@ -31,330 +30,327 @@ import org.apache.isis.core.progmodel.fa
import org.apache.isis.progmodel.wrapper.applib.HiddenException;
import org.apache.isis.viewer.junit.sample.domain.Country;
import org.junit.Test;
-
-
-public class MemberHiddenTest extends AbstractTest {
-
- @Test
- public void whenValueHiddenImperativelyForValueThenModifyThrowsException() {
- custJsDO.hideFirstName = true;
- try {
- custJsWO.setFirstName("Dick");
- fail("Should have thrown exception");
- } catch (final HiddenException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(HideForContextFacetViaMethod.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("First Name"));
- }
- }
-
- @Test
- public void whenValueHiddenImperativelyForNullThenModifyThrowsException() {
- custJsDO.hideFirstName = true;
- try {
- custJsWO.setFirstName("Dick");
- fail("Should have thrown exception");
- } catch (final HiddenException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(HideForContextFacetViaMethod.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("First Name"));
- }
- }
-
- @Test
- public void whenValueHiddenImperativelyThenReadThrowsException() {
- custJsDO.hideFirstName = true;
- try {
- custJsWO.getFirstName();
- fail("Should have thrown exception");
- } catch (final HiddenException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(HideForContextFacetViaMethod.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("First Name"));
- }
- }
-
- @Test
- public void whenAssociationHiddenImperativelyForValueThenModifyThrowsException() {
- custJsDO.hideCountryOfBirth = true;
- try {
- custJsWO.setCountryOfBirth(countryUsaDO);
- fail("Should have thrown exception");
- } catch (final HiddenException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(HideForContextFacetViaMethod.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Country Of Birth"));
- }
- }
-
-
- @Test
- public void whenAssociationHiddenImperativelyForNullThenModifyThrowsException() {
- custJsDO.hideCountryOfBirth = true;
- try {
- custJsWO.setCountryOfBirth(null);
- fail("Should have thrown exception");
- } catch (final HiddenException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(HideForContextFacetViaMethod.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Country Of Birth"));
- }
- }
-
- @Test
- public void whenAssociationHiddenImperativelyThenReadThrowsException() {
- custJsDO.hideCountryOfBirth = true;
- try {
- custJsWO.getCountryOfBirth();
- fail("Should have thrown exception");
- } catch (final HiddenException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(HideForContextFacetViaMethod.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Country Of Birth"));
- }
- }
-
- @Test
- public void whenIfCollectionHiddenImperativelyThenAddToThrowsException() {
- custJsDO.hideVisitedCountries = true;
- try {
- custJsWO.addToVisitedCountries(countryGbrDO);
- fail("Should have thrown exception");
- } catch (final HiddenException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(HideForContextFacetViaMethod.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Visited Countries"));
- }
- }
-
- @Test
- public void whenCollectionHiddenImperativelyThenRemoveFromThrowsException() {
- custJsDO.hideVisitedCountries = true;
- custJsDO.addToVisitedCountries(countryGbrDO);
- try {
- custJsWO.removeFromVisitedCountries(countryGbrDO);
- fail("Should have thrown exception");
- } catch (final HiddenException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(HideForContextFacetViaMethod.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Visited Countries"));
- }
- }
-
- @Test
- public void whenCollectionHiddenImperativelyThenReadThrowsException() {
- custJsDO.hideVisitedCountries = true;
- custJsDO.addToVisitedCountries(countryGbrDO);
- try {
- custJsWO.getVisitedCountries();
- fail("Should have thrown exception");
- } catch (final HiddenException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(HideForContextFacetViaMethod.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Visited Countries"));
- }
- }
-
- @Test
- public void whenActionHiddenImperativelyThenThrowsException() {
- custJsDO.hidePlaceOrder = true;
- try {
- custJsWO.placeOrder(product355DO, 3);
- fail("Should have thrown exception");
- } catch (final HiddenException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(HideForContextFacetViaMethod.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Place Order"));
- }
- }
-
- @Test
- public void whenValueHiddenDeclarativelyForValueThenModifyThrowsException() {
- try {
- custJsWO.setAlwaysHiddenValue("Dick");
- fail("Should have thrown exception");
- } catch (final HiddenException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(HiddenFacetForMemberAnnotation.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Always Hidden Value"));
- }
- }
-
- @Test
- public void whenValueHiddenDeclarativelyForNullThenModifyThrowsException() {
- try {
- custJsWO.setAlwaysHiddenValue(null);
- fail("Should have thrown exception");
- } catch (final HiddenException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(HiddenFacetForMemberAnnotation.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Always Hidden Value"));
- }
- }
-
- @Test
- public void whenValueHiddenDeclarativelyThenReadThrowsException() {
- try {
- custJsWO.getAlwaysHiddenValue();
- fail("Should have thrown exception");
- } catch (final HiddenException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(HiddenFacetForMemberAnnotation.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Always Hidden Value"));
- }
- }
-
- @Test
- public void whenAssociationHiddenDeclarativelyThenModifyThrowsException() {
- final Country[] values = new Country[] { countryUsaDO, null };
- for (final Country value : values) {
- try {
- custJsWO.setAlwaysHiddenAssociation(value);
- fail("Should have thrown exception");
- } catch (final HiddenException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(HiddenFacetForMemberAnnotation.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Always Hidden Association"));
- }
- }
- }
-
- @Test
- public void whenAssociationHiddenDeclarativelyThenReadThrowsException() {
- try {
- custJsWO.getAlwaysHiddenAssociation();
- fail("Should have thrown exception");
- } catch (final HiddenException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(HiddenFacetForMemberAnnotation.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Always Hidden Association"));
- }
- }
-
- @Test
- public void whenCollectionHiddenDeclarativelyThenAddToThrowsException() {
- try {
- custJsWO.addToAlwaysHiddenCollection(countryUsaDO);
- fail("Should have thrown exception");
- } catch (final HiddenException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(HiddenFacetForMemberAnnotation.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Always Hidden Collection"));
- }
- }
-
- @Test
- public void whenCollectionHiddenDeclarativelyThenRemoveFromThrowsException() {
- custJsDO.removeFromAlwaysHiddenCollection(countryUsaDO);
- try {
- custJsWO.removeFromAlwaysHiddenCollection(countryUsaDO);
- fail("Should have thrown exception");
- } catch (final HiddenException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(HiddenFacetForMemberAnnotation.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Always Hidden Collection"));
- }
- }
-
- @Test
- public void whenCollectionHiddenDeclarativelyThenReadThrowsException() {
- try {
- custJsWO.getAlwaysHiddenCollection();
- fail("Should have thrown exception");
- } catch (final HiddenException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(HiddenFacetForMemberAnnotation.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Always Hidden Collection"));
- }
- }
-
- @Test
- public void whenActionHiddenDeclarativelyThenThrowsException() {
- try {
- custJsWO.alwaysHiddenAction();
- fail("Should have thrown exception");
- } catch (final HiddenException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(HiddenFacetForMemberAnnotation.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Always Hidden Action"));
- }
- }
-
-
- @Test
- public void whenValueHiddenNotAuthorizedThenModifyThrowsException() {
- final String[] values = new String[] { "Dick", null };
- for (final String value : values) {
- try {
- custJsWO.setSessionHiddenValue(value);
- fail("Should have thrown exception");
- } catch (final HiddenException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(HideForSessionFacetViaMethod.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Session Hidden Value"));
- }
- }
- }
-
- @Test
- public void whenValueHiddenNotAuthorizedThenReadThrowsException() {
- try {
- custJsWO.getSessionHiddenValue();
- fail("Should have thrown exception");
- } catch (final HiddenException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(HideForSessionFacetViaMethod.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Session Hidden Value"));
- }
- }
-
- @Test
- public void whenAssociationHiddenNotAuthorizedThenModifyThrowsException() {
- final Country[] values = new Country[] { countryUsaDO, null };
- for (final Country value : values) {
- try {
- custJsWO.setSessionHiddenAssociation(value);
- fail("Should have thrown exception");
- } catch (final HiddenException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(HideForSessionFacetViaMethod.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Session Hidden Association"));
- }
- }
- }
-
- @Test
- public void whenAssociationHiddenNotAuthorizedThenReadThrowsException() {
- try {
- custJsWO.getSessionHiddenAssociation();
- fail("Should have thrown exception");
- } catch (final HiddenException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(HideForSessionFacetViaMethod.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Session Hidden Association"));
- }
- }
-
- @Test
- public void whenCollectionHiddenNotAuthorizedThenAddToThrowsException() {
- try {
- custJsWO.addToSessionHiddenCollection(countryUsaDO);
- fail("Should have thrown exception");
- } catch (final HiddenException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(HideForSessionFacetViaMethod.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Session Hidden Collection"));
- }
- }
-
- @Test
- public void whenCollectionHiddenNotAuthorizedThenRemoveFromThrowsException() {
- custJsDO.addToSessionHiddenCollection(countryUsaDO);
- try {
- custJsWO.removeFromSessionHiddenCollection(countryUsaDO);
- fail("Should have thrown exception");
- } catch (final HiddenException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(HideForSessionFacetViaMethod.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Session Hidden Collection"));
- }
- }
-
- @Test
- public void whenCollectionHiddenNotAuthorizedThenReadThrowsException() {
- try {
- custJsWO.getSessionHiddenCollection();
- fail("Should have thrown exception");
- } catch (final HiddenException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(HideForSessionFacetViaMethod.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Session Hidden Collection"));
- }
- }
-
- @Test
- public void whenActionHiddenNotAuthorizedThenThrowsException() {
- try {
- custJsWO.sessionHiddenAction();
- fail("Should have thrown exception");
- } catch (final HiddenException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(HideForSessionFacetViaMethod.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Session Hidden Action"));
- }
- }
-
-}
+
+public class MemberHiddenTest extends AbstractTest {
+
+ @Test
+ public void whenValueHiddenImperativelyForValueThenModifyThrowsException() {
+ custJsDO.hideFirstName = true;
+ try {
+ custJsWO.setFirstName("Dick");
+ fail("Should have thrown exception");
+ } catch (final HiddenException ex) {
+ assertThat(ex.getAdvisorClass(), classEqualTo(HideForContextFacetViaMethod.class));
+ assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("First Name"));
+ }
+ }
+
+ @Test
+ public void whenValueHiddenImperativelyForNullThenModifyThrowsException() {
+ custJsDO.hideFirstName = true;
+ try {
+ custJsWO.setFirstName("Dick");
+ fail("Should have thrown exception");
+ } catch (final HiddenException ex) {
+ assertThat(ex.getAdvisorClass(), classEqualTo(HideForContextFacetViaMethod.class));
+ assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("First Name"));
+ }
+ }
+
+ @Test
+ public void whenValueHiddenImperativelyThenReadThrowsException() {
+ custJsDO.hideFirstName = true;
+ try {
+ custJsWO.getFirstName();
+ fail("Should have thrown exception");
+ } catch (final HiddenException ex) {
+ assertThat(ex.getAdvisorClass(), classEqualTo(HideForContextFacetViaMethod.class));
+ assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("First Name"));
+ }
+ }
+
+ @Test
+ public void whenAssociationHiddenImperativelyForValueThenModifyThrowsException() {
+ custJsDO.hideCountryOfBirth = true;
+ try {
+ custJsWO.setCountryOfBirth(countryUsaDO);
+ fail("Should have thrown exception");
+ } catch (final HiddenException ex) {
+ assertThat(ex.getAdvisorClass(), classEqualTo(HideForContextFacetViaMethod.class));
+ assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Country Of Birth"));
+ }
+ }
+
+ @Test
+ public void whenAssociationHiddenImperativelyForNullThenModifyThrowsException() {
+ custJsDO.hideCountryOfBirth = true;
+ try {
+ custJsWO.setCountryOfBirth(null);
+ fail("Should have thrown exception");
+ } catch (final HiddenException ex) {
+ assertThat(ex.getAdvisorClass(), classEqualTo(HideForContextFacetViaMethod.class));
+ assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Country Of Birth"));
+ }
+ }
+
+ @Test
+ public void whenAssociationHiddenImperativelyThenReadThrowsException() {
+ custJsDO.hideCountryOfBirth = true;
+ try {
+ custJsWO.getCountryOfBirth();
+ fail("Should have thrown exception");
+ } catch (final HiddenException ex) {
+ assertThat(ex.getAdvisorClass(), classEqualTo(HideForContextFacetViaMethod.class));
+ assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Country Of Birth"));
+ }
+ }
+
+ @Test
+ public void whenIfCollectionHiddenImperativelyThenAddToThrowsException() {
+ custJsDO.hideVisitedCountries = true;
+ try {
+ custJsWO.addToVisitedCountries(countryGbrDO);
+ fail("Should have thrown exception");
+ } catch (final HiddenException ex) {
+ assertThat(ex.getAdvisorClass(), classEqualTo(HideForContextFacetViaMethod.class));
+ assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Visited Countries"));
+ }
+ }
+
+ @Test
+ public void whenCollectionHiddenImperativelyThenRemoveFromThrowsException() {
+ custJsDO.hideVisitedCountries = true;
+ custJsDO.addToVisitedCountries(countryGbrDO);
+ try {
+ custJsWO.removeFromVisitedCountries(countryGbrDO);
+ fail("Should have thrown exception");
+ } catch (final HiddenException ex) {
+ assertThat(ex.getAdvisorClass(), classEqualTo(HideForContextFacetViaMethod.class));
+ assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Visited Countries"));
+ }
+ }
+
+ @Test
+ public void whenCollectionHiddenImperativelyThenReadThrowsException() {
+ custJsDO.hideVisitedCountries = true;
+ custJsDO.addToVisitedCountries(countryGbrDO);
+ try {
+ custJsWO.getVisitedCountries();
+ fail("Should have thrown exception");
+ } catch (final HiddenException ex) {
+ assertThat(ex.getAdvisorClass(), classEqualTo(HideForContextFacetViaMethod.class));
+ assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Visited Countries"));
+ }
+ }
+
+ @Test
+ public void whenActionHiddenImperativelyThenThrowsException() {
+ custJsDO.hidePlaceOrder = true;
+ try {
+ custJsWO.placeOrder(product355DO, 3);
+ fail("Should have thrown exception");
+ } catch (final HiddenException ex) {
+ assertThat(ex.getAdvisorClass(), classEqualTo(HideForContextFacetViaMethod.class));
+ assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Place Order"));
+ }
+ }
+
+ @Test
+ public void whenValueHiddenDeclarativelyForValueThenModifyThrowsException() {
+ try {
+ custJsWO.setAlwaysHiddenValue("Dick");
+ fail("Should have thrown exception");
+ } catch (final HiddenException ex) {
+ assertThat(ex.getAdvisorClass(), classEqualTo(HiddenFacetForMemberAnnotation.class));
+ assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Always Hidden Value"));
+ }
+ }
+
+ @Test
+ public void whenValueHiddenDeclarativelyForNullThenModifyThrowsException() {
+ try {
+ custJsWO.setAlwaysHiddenValue(null);
+ fail("Should have thrown exception");
+ } catch (final HiddenException ex) {
+ assertThat(ex.getAdvisorClass(), classEqualTo(HiddenFacetForMemberAnnotation.class));
+ assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Always Hidden Value"));
+ }
+ }
+
+ @Test
+ public void whenValueHiddenDeclarativelyThenReadThrowsException() {
+ try {
+ custJsWO.getAlwaysHiddenValue();
+ fail("Should have thrown exception");
+ } catch (final HiddenException ex) {
+ assertThat(ex.getAdvisorClass(), classEqualTo(HiddenFacetForMemberAnnotation.class));
+ assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Always Hidden Value"));
+ }
+ }
+
+ @Test
+ public void whenAssociationHiddenDeclarativelyThenModifyThrowsException() {
+ final Country[] values = new Country[] { countryUsaDO, null };
+ for (final Country value : values) {
+ try {
+ custJsWO.setAlwaysHiddenAssociation(value);
+ fail("Should have thrown exception");
+ } catch (final HiddenException ex) {
+ assertThat(ex.getAdvisorClass(), classEqualTo(HiddenFacetForMemberAnnotation.class));
+ assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Always Hidden Association"));
+ }
+ }
+ }
+
+ @Test
+ public void whenAssociationHiddenDeclarativelyThenReadThrowsException() {
+ try {
+ custJsWO.getAlwaysHiddenAssociation();
+ fail("Should have thrown exception");
+ } catch (final HiddenException ex) {
+ assertThat(ex.getAdvisorClass(), classEqualTo(HiddenFacetForMemberAnnotation.class));
+ assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Always Hidden Association"));
+ }
+ }
+
+ @Test
+ public void whenCollectionHiddenDeclarativelyThenAddToThrowsException() {
+ try {
+ custJsWO.addToAlwaysHiddenCollection(countryUsaDO);
+ fail("Should have thrown exception");
+ } catch (final HiddenException ex) {
+ assertThat(ex.getAdvisorClass(), classEqualTo(HiddenFacetForMemberAnnotation.class));
+ assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Always Hidden Collection"));
+ }
+ }
+
+ @Test
+ public void whenCollectionHiddenDeclarativelyThenRemoveFromThrowsException() {
+ custJsDO.removeFromAlwaysHiddenCollection(countryUsaDO);
+ try {
+ custJsWO.removeFromAlwaysHiddenCollection(countryUsaDO);
+ fail("Should have thrown exception");
+ } catch (final HiddenException ex) {
+ assertThat(ex.getAdvisorClass(), classEqualTo(HiddenFacetForMemberAnnotation.class));
+ assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Always Hidden Collection"));
+ }
+ }
+
+ @Test
+ public void whenCollectionHiddenDeclarativelyThenReadThrowsException() {
+ try {
+ custJsWO.getAlwaysHiddenCollection();
+ fail("Should have thrown exception");
+ } catch (final HiddenException ex) {
+ assertThat(ex.getAdvisorClass(), classEqualTo(HiddenFacetForMemberAnnotation.class));
+ assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Always Hidden Collection"));
+ }
+ }
+
+ @Test
+ public void whenActionHiddenDeclarativelyThenThrowsException() {
+ try {
+ custJsWO.alwaysHiddenAction();
+ fail("Should have thrown exception");
+ } catch (final HiddenException ex) {
+ assertThat(ex.getAdvisorClass(), classEqualTo(HiddenFacetForMemberAnnotation.class));
+ assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Always Hidden Action"));
+ }
+ }
+
+ @Test
+ public void whenValueHiddenNotAuthorizedThenModifyThrowsException() {
+ final String[] values = new String[] { "Dick", null };
+ for (final String value : values) {
+ try {
+ custJsWO.setSessionHiddenValue(value);
+ fail("Should have thrown exception");
+ } catch (final HiddenException ex) {
+ assertThat(ex.getAdvisorClass(), classEqualTo(HideForSessionFacetViaMethod.class));
+ assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Session Hidden Value"));
+ }
+ }
+ }
+
+ @Test
+ public void whenValueHiddenNotAuthorizedThenReadThrowsException() {
+ try {
+ custJsWO.getSessionHiddenValue();
+ fail("Should have thrown exception");
+ } catch (final HiddenException ex) {
+ assertThat(ex.getAdvisorClass(), classEqualTo(HideForSessionFacetViaMethod.class));
+ assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Session Hidden Value"));
+ }
+ }
+
+ @Test
+ public void whenAssociationHiddenNotAuthorizedThenModifyThrowsException() {
+ final Country[] values = new Country[] { countryUsaDO, null };
+ for (final Country value : values) {
+ try {
+ custJsWO.setSessionHiddenAssociation(value);
+ fail("Should have thrown exception");
+ } catch (final HiddenException ex) {
+ assertThat(ex.getAdvisorClass(), classEqualTo(HideForSessionFacetViaMethod.class));
+ assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Session Hidden Association"));
+ }
+ }
+ }
+
+ @Test
+ public void whenAssociationHiddenNotAuthorizedThenReadThrowsException() {
+ try {
+ custJsWO.getSessionHiddenAssociation();
+ fail("Should have thrown exception");
+ } catch (final HiddenException ex) {
+ assertThat(ex.getAdvisorClass(), classEqualTo(HideForSessionFacetViaMethod.class));
+ assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Session Hidden Association"));
+ }
+ }
+
+ @Test
+ public void whenCollectionHiddenNotAuthorizedThenAddToThrowsException() {
+ try {
+ custJsWO.addToSessionHiddenCollection(countryUsaDO);
+ fail("Should have thrown exception");
+ } catch (final HiddenException ex) {
+ assertThat(ex.getAdvisorClass(), classEqualTo(HideForSessionFacetViaMethod.class));
+ assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Session Hidden Collection"));
+ }
+ }
+
+ @Test
+ public void whenCollectionHiddenNotAuthorizedThenRemoveFromThrowsException() {
+ custJsDO.addToSessionHiddenCollection(countryUsaDO);
+ try {
+ custJsWO.removeFromSessionHiddenCollection(countryUsaDO);
+ fail("Should have thrown exception");
+ } catch (final HiddenException ex) {
+ assertThat(ex.getAdvisorClass(), classEqualTo(HideForSessionFacetViaMethod.class));
+ assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Session Hidden Collection"));
+ }
+ }
+
+ @Test
+ public void whenCollectionHiddenNotAuthorizedThenReadThrowsException() {
+ try {
+ custJsWO.getSessionHiddenCollection();
+ fail("Should have thrown exception");
+ } catch (final HiddenException ex) {
+ assertThat(ex.getAdvisorClass(), classEqualTo(HideForSessionFacetViaMethod.class));
+ assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Session Hidden Collection"));
+ }
+ }
+
+ @Test
+ public void whenActionHiddenNotAuthorizedThenThrowsException() {
+ try {
+ custJsWO.sessionHiddenAction();
+ fail("Should have thrown exception");
+ } catch (final HiddenException ex) {
+ assertThat(ex.getAdvisorClass(), classEqualTo(HideForSessionFacetViaMethod.class));
+ assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Session Hidden Action"));
+ }
+ }
+
+}
Modified: incubator/isis/trunk/viewer/junit/src/test/java/org/apache/isis/viewer/junit/MemberInvalidTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/junit/src/test/java/org/apache/isis/viewer/junit/MemberInvalidTest.java?rev=1098951&r1=1098950&r2=1098951&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/junit/src/test/java/org/apache/isis/viewer/junit/MemberInvalidTest.java (original)
+++ incubator/isis/trunk/viewer/junit/src/test/java/org/apache/isis/viewer/junit/MemberInvalidTest.java Tue May 3 07:53:06 2011
@@ -17,16 +17,13 @@
* under the License.
*/
+package org.apache.isis.viewer.junit;
-package org.apache.isis.viewer.junit;
-
import static org.apache.isis.core.commons.matchers.IsisMatchers.classEqualTo;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
-import org.junit.Test;
-
import org.apache.isis.core.metamodel.facets.mandatory.MandatoryFacetDefault;
import org.apache.isis.core.progmodel.facets.actions.validate.method.ActionValidationFacetViaMethod;
import org.apache.isis.core.progmodel.facets.collections.validate.CollectionValidateAddToFacetViaMethod;
@@ -36,158 +33,156 @@ import org.apache.isis.core.progmodel.fa
import org.apache.isis.core.progmodel.facets.properties.validate.regexannot.RegExFacetAnnotationForProperty;
import org.apache.isis.progmodel.wrapper.applib.InvalidException;
import org.apache.isis.viewer.junit.sample.domain.Country;
-
-
-public class MemberInvalidTest extends AbstractTest {
-
- @Test
- public void whenValueInvalidImperativelyThenThrowsException() {
- final String[] values = new String[] { "Dick", null };
- for (final String value : values) {
- custJsDO.validateFirstNameExpectedArg = value;
- custJsDO.validateFirstName = "bad first name";
- try {
- custJsWO.setFirstName(value);
- fail("Should have thrown exception");
- } catch (final InvalidException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(PropertyValidateFacetViaMethod.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("First Name"));
- assertThat(ex.getMessage(), equalTo("bad first name"));
- }
- }
- }
-
- @Test
- public void whenAssociationInvalidImperativelyThenThrowsException() {
- custJsDO.validateCountryOfBirth = "bad country of birth";
- final Country[] values = new Country[] { countryUsaDO, null };
- for (final Country value : values) {
- try {
- custJsWO.setCountryOfBirth(value);
- fail("Should have thrown exception");
- } catch (final InvalidException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(PropertyValidateFacetViaMethod.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Country Of Birth"));
- assertThat(ex.getMessage(), equalTo("bad country of birth"));
- }
- }
- }
-
- @Test
- public void whenCollectionInvalidImperativelyThenAddToThrowsException() {
- custJsDO.validateAddToVisitedCountries = "bad country";
- try {
- custJsWO.addToVisitedCountries(countryGbrDO);
- fail("Should have thrown exception");
- } catch (final InvalidException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(CollectionValidateAddToFacetViaMethod.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Visited Countries"));
- assertThat(ex.getMessage(), equalTo("bad country"));
- }
- }
-
- @Test
- public void whenCollectionInvalidImperativelyThenRemoveFromThrowsException() {
- custJsDO.addToVisitedCountries(countryGbrDO);
- custJsDO.validateRemoveFromVisitedCountries = "bad country";
- try {
- custJsWO.removeFromVisitedCountries(countryGbrDO);
- fail("Should have thrown exception");
- } catch (final InvalidException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(CollectionValidateRemoveFromFacetViaMethod.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Visited Countries"));
- assertThat(ex.getMessage(), equalTo("bad country"));
- }
- }
-
- @Test
- public void whenActionInvalidImperativelyThenThrowsException() {
- custJsDO.validatePlaceOrder = "can't place order";
- try {
- custJsWO.placeOrder(product355DO, 3);
- fail("Should have thrown exception");
- } catch (final InvalidException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(ActionValidationFacetViaMethod.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Place Order"));
- assertThat(ex.getMessage(), equalTo("can't place order"));
- }
- }
-
- @Test
- public void whenValueCanSetNullOnOptionalField() {
- custJsWO.setOptionalValue(null);
- }
-
- @Test
- public void whenAssociationCanSetNullOnOptionalField() {
- custJsWO.setOptionalAssociation(null);
- }
-
- @Test
- public void whenValueInvalidMandatoryThenThrowsException() {
- try {
- custJsWO.setMandatoryValue(null);
- fail("Should have thrown exception");
- } catch (final InvalidException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(MandatoryFacetDefault.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Mandatory Value"));
- }
- }
-
- @Test
- public void whenAssociationInvalidMandatoryThenThrowsException() {
- try {
- custJsWO.setMandatoryAssociation(null);
- fail("Should have thrown exception");
- } catch (final InvalidException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(MandatoryFacetDefault.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Mandatory Association"));
- }
- }
-
-
- @Test
- public void whenInvalidMaxLengthThenThrowsException() {
- try {
- custJsWO.setMaxLengthField("This is far too long");
- fail("Should have thrown exception");
- } catch (final InvalidException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(MaxLengthFacetAnnotationForProperty.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Max Length Field"));
- }
- }
-
-
- @Test
- public void whenInvalidRegExCaseSensitiveThenThrowsException() {
- try {
- custJsWO.setRegExCaseSensitiveField("abCfoobar");
- fail("Should have thrown exception");
- } catch (final InvalidException ex) {
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Reg Ex Case Sensitive Field"));
- }
- }
-
- @Test
- public void whenCanSetValidRegExCaseSensitive() {
- custJsWO.setRegExCaseInsensitiveField("abcfoobar");
-
- }
-
- @Test
- public void whenInvalidRegExCaseInsensitiveThenThrowsException() {
- try {
- custJsWO.setRegExCaseInsensitiveField("abXfoobar");
- fail("Should have thrown exception");
- } catch (final InvalidException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(RegExFacetAnnotationForProperty.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Reg Ex Case Insensitive Field"));
- }
- }
-
- @Test
- public void whenCanSetValidRegExCaseInsensitive() {
- custJsWO.setRegExCaseInsensitiveField("AbCfoobar");
- }
-
-}
+import org.junit.Test;
+
+public class MemberInvalidTest extends AbstractTest {
+
+ @Test
+ public void whenValueInvalidImperativelyThenThrowsException() {
+ final String[] values = new String[] { "Dick", null };
+ for (final String value : values) {
+ custJsDO.validateFirstNameExpectedArg = value;
+ custJsDO.validateFirstName = "bad first name";
+ try {
+ custJsWO.setFirstName(value);
+ fail("Should have thrown exception");
+ } catch (final InvalidException ex) {
+ assertThat(ex.getAdvisorClass(), classEqualTo(PropertyValidateFacetViaMethod.class));
+ assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("First Name"));
+ assertThat(ex.getMessage(), equalTo("bad first name"));
+ }
+ }
+ }
+
+ @Test
+ public void whenAssociationInvalidImperativelyThenThrowsException() {
+ custJsDO.validateCountryOfBirth = "bad country of birth";
+ final Country[] values = new Country[] { countryUsaDO, null };
+ for (final Country value : values) {
+ try {
+ custJsWO.setCountryOfBirth(value);
+ fail("Should have thrown exception");
+ } catch (final InvalidException ex) {
+ assertThat(ex.getAdvisorClass(), classEqualTo(PropertyValidateFacetViaMethod.class));
+ assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Country Of Birth"));
+ assertThat(ex.getMessage(), equalTo("bad country of birth"));
+ }
+ }
+ }
+
+ @Test
+ public void whenCollectionInvalidImperativelyThenAddToThrowsException() {
+ custJsDO.validateAddToVisitedCountries = "bad country";
+ try {
+ custJsWO.addToVisitedCountries(countryGbrDO);
+ fail("Should have thrown exception");
+ } catch (final InvalidException ex) {
+ assertThat(ex.getAdvisorClass(), classEqualTo(CollectionValidateAddToFacetViaMethod.class));
+ assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Visited Countries"));
+ assertThat(ex.getMessage(), equalTo("bad country"));
+ }
+ }
+
+ @Test
+ public void whenCollectionInvalidImperativelyThenRemoveFromThrowsException() {
+ custJsDO.addToVisitedCountries(countryGbrDO);
+ custJsDO.validateRemoveFromVisitedCountries = "bad country";
+ try {
+ custJsWO.removeFromVisitedCountries(countryGbrDO);
+ fail("Should have thrown exception");
+ } catch (final InvalidException ex) {
+ assertThat(ex.getAdvisorClass(), classEqualTo(CollectionValidateRemoveFromFacetViaMethod.class));
+ assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Visited Countries"));
+ assertThat(ex.getMessage(), equalTo("bad country"));
+ }
+ }
+
+ @Test
+ public void whenActionInvalidImperativelyThenThrowsException() {
+ custJsDO.validatePlaceOrder = "can't place order";
+ try {
+ custJsWO.placeOrder(product355DO, 3);
+ fail("Should have thrown exception");
+ } catch (final InvalidException ex) {
+ assertThat(ex.getAdvisorClass(), classEqualTo(ActionValidationFacetViaMethod.class));
+ assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Place Order"));
+ assertThat(ex.getMessage(), equalTo("can't place order"));
+ }
+ }
+
+ @Test
+ public void whenValueCanSetNullOnOptionalField() {
+ custJsWO.setOptionalValue(null);
+ }
+
+ @Test
+ public void whenAssociationCanSetNullOnOptionalField() {
+ custJsWO.setOptionalAssociation(null);
+ }
+
+ @Test
+ public void whenValueInvalidMandatoryThenThrowsException() {
+ try {
+ custJsWO.setMandatoryValue(null);
+ fail("Should have thrown exception");
+ } catch (final InvalidException ex) {
+ assertThat(ex.getAdvisorClass(), classEqualTo(MandatoryFacetDefault.class));
+ assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Mandatory Value"));
+ }
+ }
+
+ @Test
+ public void whenAssociationInvalidMandatoryThenThrowsException() {
+ try {
+ custJsWO.setMandatoryAssociation(null);
+ fail("Should have thrown exception");
+ } catch (final InvalidException ex) {
+ assertThat(ex.getAdvisorClass(), classEqualTo(MandatoryFacetDefault.class));
+ assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Mandatory Association"));
+ }
+ }
+
+ @Test
+ public void whenInvalidMaxLengthThenThrowsException() {
+ try {
+ custJsWO.setMaxLengthField("This is far too long");
+ fail("Should have thrown exception");
+ } catch (final InvalidException ex) {
+ assertThat(ex.getAdvisorClass(), classEqualTo(MaxLengthFacetAnnotationForProperty.class));
+ assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Max Length Field"));
+ }
+ }
+
+ @Test
+ public void whenInvalidRegExCaseSensitiveThenThrowsException() {
+ try {
+ custJsWO.setRegExCaseSensitiveField("abCfoobar");
+ fail("Should have thrown exception");
+ } catch (final InvalidException ex) {
+ assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Reg Ex Case Sensitive Field"));
+ }
+ }
+
+ @Test
+ public void whenCanSetValidRegExCaseSensitive() {
+ custJsWO.setRegExCaseInsensitiveField("abcfoobar");
+
+ }
+
+ @Test
+ public void whenInvalidRegExCaseInsensitiveThenThrowsException() {
+ try {
+ custJsWO.setRegExCaseInsensitiveField("abXfoobar");
+ fail("Should have thrown exception");
+ } catch (final InvalidException ex) {
+ assertThat(ex.getAdvisorClass(), classEqualTo(RegExFacetAnnotationForProperty.class));
+ assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Reg Ex Case Insensitive Field"));
+ }
+ }
+
+ @Test
+ public void whenCanSetValidRegExCaseInsensitive() {
+ custJsWO.setRegExCaseInsensitiveField("AbCfoobar");
+ }
+
+}
Modified: incubator/isis/trunk/viewer/junit/src/test/java/org/apache/isis/viewer/junit/MemberModifyTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/junit/src/test/java/org/apache/isis/viewer/junit/MemberModifyTest.java?rev=1098951&r1=1098950&r2=1098951&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/junit/src/test/java/org/apache/isis/viewer/junit/MemberModifyTest.java (original)
+++ incubator/isis/trunk/viewer/junit/src/test/java/org/apache/isis/viewer/junit/MemberModifyTest.java Tue May 3 07:53:06 2011
@@ -17,9 +17,8 @@
* under the License.
*/
+package org.apache.isis.viewer.junit;
-package org.apache.isis.viewer.junit;
-
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
@@ -33,189 +32,188 @@ import org.apache.isis.progmodel.wrapper
import org.apache.isis.viewer.junit.sample.domain.Country;
import org.apache.isis.viewer.junit.sample.domain.Order;
import org.junit.Test;
-
-
-public class MemberModifyTest extends AbstractTest {
-
- @Test
- public void valueModifiedToNonNull() {
- custJsWO.setFirstName("Dick");
-
- assertThat(custJsWO.getFirstName(), equalTo("Dick"));
- }
-
- @Test
- public void valueModifiedToNull() {
- custJsWO.setFirstName(null);
-
- assertThat(custJsWO.getFirstName(), nullValue());
- }
-
- @Test
- public void whenValueModifyCalledRatherThanSetForNonNull() {
- custJsWO.setFirstName("Dick");
- assertThat(custJsDO.modifyFirstNameCalled, is(true));
- }
-
- @Test
- public void whenValueClearCalledRatherThanSetForNull() {
- custJsWO.setFirstName(null);
- assertThat(custJsDO.clearFirstNameCalled, is(true));
- }
-
- @Test
- public void whenAssociationModifyCalledRatherThanSetForNonNull() {
- custJsWO.setCountryOfBirth(countryUsaDO);
- assertThat(custJsDO.modifyCountryOfBirthCalled, is(true));
- }
-
- @Test
- public void whenAssociationClearCalledRatherThanSetForNull() {
- custJsWO.setCountryOfBirth(null);
- assertThat(custJsDO.clearCountryOfBirthCalled, is(true));
- }
-
- @Test
- public void cannotUseAddDirectlyOnCollections() {
- final List<Country> visitedCountries = custJsWO.getVisitedCountries();
- try {
- visitedCountries.add(countryGbrDO);
- fail("UnsupportedOperationException should have been thrown.");
- } catch (final UnsupportedOperationException ex) {
- // expected
- }
- }
-
- @Test
- public void cannotUseRemoveDirectlyOnCollections() {
- final List<Country> visitedCountries = custJsWO.getVisitedCountries();
- try {
- visitedCountries.remove(countryGbrDO);
- fail("UnsupportedOperationException should have been thrown.");
- } catch (final UnsupportedOperationException ex) {
- // expected
- }
- }
-
- @Test
- public void cannotUseClearDirectlyOnCollections() {
- final List<Country> visitedCountries = custJsWO.getVisitedCountries();
- try {
- visitedCountries.clear();
- fail("UnsupportedOperationException should have been thrown.");
- } catch (final UnsupportedOperationException ex) {
- // expected
- }
- }
-
- @Test
- public void sttemptingToAddNullObjectIntoCollectionThrowsException() {
- try {
- custJsWO.addToVisitedCountries(null);
- fail("Exception should have been raised.");
- } catch (final IllegalArgumentException ex) {
- // expected
- }
- }
-
- @Test
- public void removingNonExistentRemoveObjectFromCollectionDoesNothing() {
- assertThat(custJsDO.getVisitedCountries().contains(countryGbrDO), is(false));
-
- custJsWO.removeFromVisitedCountries(countryGbrDO);
- // no exception raised.
- }
-
- @Test
- public void canInvokeAction() {
- final int sizeBefore = custJsWO.getOrders().size();
- final Order orderBefore = custJsWO.getLastOrder();
- custJsWO.placeOrder(product355DO, 3);
- final Order orderAfter = custJsWO.getLastOrder();
-
- final int sizeAfter = custJsWO.getOrders().size();
- assertThat(sizeAfter, is(sizeBefore + 1));
- assertThat(orderAfter, is(not(orderBefore)));
- }
-
- @Test
- public void canInvokeActionIfOptionalValueParameterAndNullArgumentProvided() {
- custJsWO.actionWithOptionalValueParameter(null);
- assertThat(custJsDO.actionWithOptionalValueParameterArgument, nullValue());
- }
-
- @Test
- public void cannotInvokeActionIfMandatoryValueParameterAndNullArgumentProvided() {
- try {
- custJsWO.actionWithMandatoryValueParameter(null);
- fail("InvalidMandatoryException should have been thrown");
- } catch (final InvalidException ex) {
- assertThat(custJsDO.actionWithMandatoryValueParameterArgument, equalTo(Long.MAX_VALUE)); // ie
- }
- }
-
- @Test
- public void canInvokeActionIfOptionalReferenceParameterAndNullArgumentProvided() {
- custJsWO.actionWithOptionalReferenceParameter(null);
- assertThat(custJsDO.actionWithOptionalReferenceParameterArgument, nullValue());
- }
-
- @Test
- public void cannotInvokeActionIfMandatoryReferenceParameterAndNullArgumentProvided() {
- try {
- custJsWO.actionWithMandatoryReferenceParameter(null);
- fail("InvalidMandatoryException should have been thrown");
- } catch (final InvalidException ex) {
- assertThat(custJsDO.actionWithMandatoryReferenceParameterArgument, not(nullValue()));
- }
- }
-
- @Test
- public void canInvokeActionIfOptionalStringParameterAndEmptyStringProvidedAsArgument() {
- custJsWO.actionWithOptionalStringParameter("");
- assertThat(custJsDO.actionWithOptionalStringParameterArgument, equalTo(""));
- }
-
- @Test
- public void cannotInvokeActionIfMandatoryStringParameterAndEmptyStringProvidedAsArgument() {
- try {
- custJsWO.actionWithMandatoryStringParameter("");
- fail("InvalidMandatoryException should have been thrown");
- } catch (final InvalidException ex) {
- assertThat(custJsDO.actionWithMandatoryStringParameterArgument, equalTo("original value")); // ie
- }
- }
-
- @Test
- public void canInvokeActionIfParameterMatchRegularExpression() {
- custJsWO.actionWithRegExStringParameter("6789");
- assertThat(custJsDO.actionWithRegExStringParameterArgument, equalTo("6789"));
- }
-
- @Test
- public void cannotInvokeActionIfParameterDoesNotMatchRegularExpression() {
- try {
- custJsWO.actionWithRegExStringParameter("abcd"); // doesn't match [0-9]{4}
- fail("InvalidRegExException should have been thrown");
- } catch (final InvalidException ex) {
- assertThat(custJsDO.actionWithRegExStringParameterArgument, equalTo("1234")); // ie unchanged
- }
- }
-
- @Test
- public void canInvokeActionIfParameterNoLongerMaximumLength() {
- custJsWO.actionWithMaxLengthStringParameter("abcd");
- assertThat(custJsDO.actionWithMaxLengthStringParameterArgument, equalTo("abcd"));
- }
-
- @Test
- public void cannotInvokeActionIfParameterExceedsMaximumLength() {
- try {
- custJsWO.actionWithMaxLengthStringParameter("abcde");
- fail("InvalidMaxLengthException should have been thrown");
- } catch (final InvalidException ex) {
- assertThat(custJsDO.actionWithMaxLengthStringParameterArgument, equalTo("1234")); // ie unchanged
- }
- }
-
-}
+
+public class MemberModifyTest extends AbstractTest {
+
+ @Test
+ public void valueModifiedToNonNull() {
+ custJsWO.setFirstName("Dick");
+
+ assertThat(custJsWO.getFirstName(), equalTo("Dick"));
+ }
+
+ @Test
+ public void valueModifiedToNull() {
+ custJsWO.setFirstName(null);
+
+ assertThat(custJsWO.getFirstName(), nullValue());
+ }
+
+ @Test
+ public void whenValueModifyCalledRatherThanSetForNonNull() {
+ custJsWO.setFirstName("Dick");
+ assertThat(custJsDO.modifyFirstNameCalled, is(true));
+ }
+
+ @Test
+ public void whenValueClearCalledRatherThanSetForNull() {
+ custJsWO.setFirstName(null);
+ assertThat(custJsDO.clearFirstNameCalled, is(true));
+ }
+
+ @Test
+ public void whenAssociationModifyCalledRatherThanSetForNonNull() {
+ custJsWO.setCountryOfBirth(countryUsaDO);
+ assertThat(custJsDO.modifyCountryOfBirthCalled, is(true));
+ }
+
+ @Test
+ public void whenAssociationClearCalledRatherThanSetForNull() {
+ custJsWO.setCountryOfBirth(null);
+ assertThat(custJsDO.clearCountryOfBirthCalled, is(true));
+ }
+
+ @Test
+ public void cannotUseAddDirectlyOnCollections() {
+ final List<Country> visitedCountries = custJsWO.getVisitedCountries();
+ try {
+ visitedCountries.add(countryGbrDO);
+ fail("UnsupportedOperationException should have been thrown.");
+ } catch (final UnsupportedOperationException ex) {
+ // expected
+ }
+ }
+
+ @Test
+ public void cannotUseRemoveDirectlyOnCollections() {
+ final List<Country> visitedCountries = custJsWO.getVisitedCountries();
+ try {
+ visitedCountries.remove(countryGbrDO);
+ fail("UnsupportedOperationException should have been thrown.");
+ } catch (final UnsupportedOperationException ex) {
+ // expected
+ }
+ }
+
+ @Test
+ public void cannotUseClearDirectlyOnCollections() {
+ final List<Country> visitedCountries = custJsWO.getVisitedCountries();
+ try {
+ visitedCountries.clear();
+ fail("UnsupportedOperationException should have been thrown.");
+ } catch (final UnsupportedOperationException ex) {
+ // expected
+ }
+ }
+
+ @Test
+ public void sttemptingToAddNullObjectIntoCollectionThrowsException() {
+ try {
+ custJsWO.addToVisitedCountries(null);
+ fail("Exception should have been raised.");
+ } catch (final IllegalArgumentException ex) {
+ // expected
+ }
+ }
+
+ @Test
+ public void removingNonExistentRemoveObjectFromCollectionDoesNothing() {
+ assertThat(custJsDO.getVisitedCountries().contains(countryGbrDO), is(false));
+
+ custJsWO.removeFromVisitedCountries(countryGbrDO);
+ // no exception raised.
+ }
+
+ @Test
+ public void canInvokeAction() {
+ final int sizeBefore = custJsWO.getOrders().size();
+ final Order orderBefore = custJsWO.getLastOrder();
+ custJsWO.placeOrder(product355DO, 3);
+ final Order orderAfter = custJsWO.getLastOrder();
+
+ final int sizeAfter = custJsWO.getOrders().size();
+ assertThat(sizeAfter, is(sizeBefore + 1));
+ assertThat(orderAfter, is(not(orderBefore)));
+ }
+
+ @Test
+ public void canInvokeActionIfOptionalValueParameterAndNullArgumentProvided() {
+ custJsWO.actionWithOptionalValueParameter(null);
+ assertThat(custJsDO.actionWithOptionalValueParameterArgument, nullValue());
+ }
+
+ @Test
+ public void cannotInvokeActionIfMandatoryValueParameterAndNullArgumentProvided() {
+ try {
+ custJsWO.actionWithMandatoryValueParameter(null);
+ fail("InvalidMandatoryException should have been thrown");
+ } catch (final InvalidException ex) {
+ assertThat(custJsDO.actionWithMandatoryValueParameterArgument, equalTo(Long.MAX_VALUE)); // ie
+ }
+ }
+
+ @Test
+ public void canInvokeActionIfOptionalReferenceParameterAndNullArgumentProvided() {
+ custJsWO.actionWithOptionalReferenceParameter(null);
+ assertThat(custJsDO.actionWithOptionalReferenceParameterArgument, nullValue());
+ }
+
+ @Test
+ public void cannotInvokeActionIfMandatoryReferenceParameterAndNullArgumentProvided() {
+ try {
+ custJsWO.actionWithMandatoryReferenceParameter(null);
+ fail("InvalidMandatoryException should have been thrown");
+ } catch (final InvalidException ex) {
+ assertThat(custJsDO.actionWithMandatoryReferenceParameterArgument, not(nullValue()));
+ }
+ }
+
+ @Test
+ public void canInvokeActionIfOptionalStringParameterAndEmptyStringProvidedAsArgument() {
+ custJsWO.actionWithOptionalStringParameter("");
+ assertThat(custJsDO.actionWithOptionalStringParameterArgument, equalTo(""));
+ }
+
+ @Test
+ public void cannotInvokeActionIfMandatoryStringParameterAndEmptyStringProvidedAsArgument() {
+ try {
+ custJsWO.actionWithMandatoryStringParameter("");
+ fail("InvalidMandatoryException should have been thrown");
+ } catch (final InvalidException ex) {
+ assertThat(custJsDO.actionWithMandatoryStringParameterArgument, equalTo("original value")); // ie
+ }
+ }
+
+ @Test
+ public void canInvokeActionIfParameterMatchRegularExpression() {
+ custJsWO.actionWithRegExStringParameter("6789");
+ assertThat(custJsDO.actionWithRegExStringParameterArgument, equalTo("6789"));
+ }
+
+ @Test
+ public void cannotInvokeActionIfParameterDoesNotMatchRegularExpression() {
+ try {
+ custJsWO.actionWithRegExStringParameter("abcd"); // doesn't match [0-9]{4}
+ fail("InvalidRegExException should have been thrown");
+ } catch (final InvalidException ex) {
+ assertThat(custJsDO.actionWithRegExStringParameterArgument, equalTo("1234")); // ie unchanged
+ }
+ }
+
+ @Test
+ public void canInvokeActionIfParameterNoLongerMaximumLength() {
+ custJsWO.actionWithMaxLengthStringParameter("abcd");
+ assertThat(custJsDO.actionWithMaxLengthStringParameterArgument, equalTo("abcd"));
+ }
+
+ @Test
+ public void cannotInvokeActionIfParameterExceedsMaximumLength() {
+ try {
+ custJsWO.actionWithMaxLengthStringParameter("abcde");
+ fail("InvalidMaxLengthException should have been thrown");
+ } catch (final InvalidException ex) {
+ assertThat(custJsDO.actionWithMaxLengthStringParameterArgument, equalTo("1234")); // ie unchanged
+ }
+ }
+
+}
Modified: incubator/isis/trunk/viewer/junit/src/test/java/org/apache/isis/viewer/junit/MemberReadTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/junit/src/test/java/org/apache/isis/viewer/junit/MemberReadTest.java?rev=1098951&r1=1098950&r2=1098951&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/junit/src/test/java/org/apache/isis/viewer/junit/MemberReadTest.java (original)
+++ incubator/isis/trunk/viewer/junit/src/test/java/org/apache/isis/viewer/junit/MemberReadTest.java Tue May 3 07:53:06 2011
@@ -17,9 +17,8 @@
* under the License.
*/
+package org.apache.isis.viewer.junit;
-package org.apache.isis.viewer.junit;
-
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.nullValue;
@@ -29,66 +28,65 @@ import java.util.List;
import org.apache.isis.viewer.junit.sample.domain.Country;
import org.junit.Test;
-
-
-public class MemberReadTest extends AbstractTest {
-
- @Test
- public void value() {
- assertThat(custJsWO.getFirstName(), equalTo("Richard"));
- }
-
- @Test
- public void valueWhenNull() {
- custJsDO.setFirstName(null);
- assertThat(custJsWO.getFirstName(), nullValue());
- }
-
- @Test
- public void association() {
- assertThat(custJsWO.getCountryOfBirth(), equalTo(countryGbrDO));
- }
-
- @Test
- public void associationWhenNull() {
- custJsDO.setCountryOfBirth(null);
- assertThat(custJsWO.getCountryOfBirth(), nullValue());
- }
-
- @Test
- public void collectionContainsWhenDoesAndDoesNot() {
- custJsDO.addToVisitedCountries(countryGbrDO);
- custJsDO.addToVisitedCountries(countryUsaDO);
- final List<Country> visitedCountries = custJsWO.getVisitedCountries();
- assertThat(visitedCountries.contains(countryGbrDO), is(true));
- assertThat(visitedCountries.contains(countryUsaDO), is(true));
- assertThat(visitedCountries.contains(countryAusDO), is(false));
- }
-
- @Test
- public void collectionSizeWhenEmpty() {
- assertThat(custJsWO.getVisitedCountries().size(), is(0));
- }
-
- @Test
- public void collectionSizeWhenNotEmpty() {
- custJsDO.addToVisitedCountries(countryGbrDO);
- custJsDO.addToVisitedCountries(countryUsaDO);
-
- assertThat(custJsWO.getVisitedCountries().size(), is(2));
- }
-
- @Test
- public void isEmptySizeWhenEmpty() {
- assertThat(custJsWO.getVisitedCountries().isEmpty(), is(true));
- }
-
- @Test
- public void isEmptySizeWhenNotEmpty() {
- custJsDO.addToVisitedCountries(countryGbrDO);
- custJsDO.addToVisitedCountries(countryUsaDO);
-
- assertThat(custJsWO.getVisitedCountries().isEmpty(), is(false));
- }
-
-}
+
+public class MemberReadTest extends AbstractTest {
+
+ @Test
+ public void value() {
+ assertThat(custJsWO.getFirstName(), equalTo("Richard"));
+ }
+
+ @Test
+ public void valueWhenNull() {
+ custJsDO.setFirstName(null);
+ assertThat(custJsWO.getFirstName(), nullValue());
+ }
+
+ @Test
+ public void association() {
+ assertThat(custJsWO.getCountryOfBirth(), equalTo(countryGbrDO));
+ }
+
+ @Test
+ public void associationWhenNull() {
+ custJsDO.setCountryOfBirth(null);
+ assertThat(custJsWO.getCountryOfBirth(), nullValue());
+ }
+
+ @Test
+ public void collectionContainsWhenDoesAndDoesNot() {
+ custJsDO.addToVisitedCountries(countryGbrDO);
+ custJsDO.addToVisitedCountries(countryUsaDO);
+ final List<Country> visitedCountries = custJsWO.getVisitedCountries();
+ assertThat(visitedCountries.contains(countryGbrDO), is(true));
+ assertThat(visitedCountries.contains(countryUsaDO), is(true));
+ assertThat(visitedCountries.contains(countryAusDO), is(false));
+ }
+
+ @Test
+ public void collectionSizeWhenEmpty() {
+ assertThat(custJsWO.getVisitedCountries().size(), is(0));
+ }
+
+ @Test
+ public void collectionSizeWhenNotEmpty() {
+ custJsDO.addToVisitedCountries(countryGbrDO);
+ custJsDO.addToVisitedCountries(countryUsaDO);
+
+ assertThat(custJsWO.getVisitedCountries().size(), is(2));
+ }
+
+ @Test
+ public void isEmptySizeWhenEmpty() {
+ assertThat(custJsWO.getVisitedCountries().isEmpty(), is(true));
+ }
+
+ @Test
+ public void isEmptySizeWhenNotEmpty() {
+ custJsDO.addToVisitedCountries(countryGbrDO);
+ custJsDO.addToVisitedCountries(countryUsaDO);
+
+ assertThat(custJsWO.getVisitedCountries().isEmpty(), is(false));
+ }
+
+}
Modified: incubator/isis/trunk/viewer/junit/src/test/java/org/apache/isis/viewer/junit/ObjectImmutableTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/junit/src/test/java/org/apache/isis/viewer/junit/ObjectImmutableTest.java?rev=1098951&r1=1098950&r2=1098951&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/junit/src/test/java/org/apache/isis/viewer/junit/ObjectImmutableTest.java (original)
+++ incubator/isis/trunk/viewer/junit/src/test/java/org/apache/isis/viewer/junit/ObjectImmutableTest.java Tue May 3 07:53:06 2011
@@ -17,72 +17,69 @@
* under the License.
*/
+package org.apache.isis.viewer.junit;
-package org.apache.isis.viewer.junit;
-
import static org.apache.isis.core.commons.matchers.IsisMatchers.classEqualTo;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
-import org.junit.Test;
-
import org.apache.isis.core.progmodel.facets.collections.disabled.fromimmutable.DisabledFacetForCollectionDerivedFromImmutable;
import org.apache.isis.core.progmodel.facets.properties.disabled.fromimmutable.DisabledFacetForPropertyDerivedFromImmutable;
import org.apache.isis.progmodel.wrapper.applib.DisabledException;
-
-
-public class ObjectImmutableTest extends AbstractTest {
-
- @Test
- public void settingValueOnImmutableObjectThrowsException() {
- try {
- product355VO.setDescription("Changed");
- fail("Should have thrown exception");
- } catch (final DisabledException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(DisabledFacetForPropertyDerivedFromImmutable.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Description"));
- }
- }
-
- @Test
- public void settingAssociationOnImmutableObjectThrowsException() {
- try {
- product355VO.setPlaceOfManufacture(countryUsaDO);
- fail("Should have thrown exception");
- } catch (final DisabledException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(DisabledFacetForPropertyDerivedFromImmutable.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Place Of Manufacture"));
- }
- }
-
- @Test
- public void addingToCollectionOnImmutableObjectThrowsException() {
- try {
- product355VO.addToSimilarProducts(product850DO);
- fail("Should have thrown exception");
- } catch (final DisabledException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(DisabledFacetForCollectionDerivedFromImmutable.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Similar Products"));
- }
- }
-
- @Test
- public void removingFromCollectionOnImmutableObjectThrowsException() {
- product355DO.addToSimilarProducts(product850DO); // TODO: can't setup, throws
- // ObjectPersistenceException
- try {
- product355VO.removeFromSimilarProducts(product850DO);
- fail("Should have thrown exception");
- } catch (final DisabledException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(DisabledFacetForCollectionDerivedFromImmutable.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Similar Products"));
- }
- }
-
- @Test
- public void canInvokingOnImmutableObject() {
- product355VO.foobar();
- }
-
-}
+import org.junit.Test;
+
+public class ObjectImmutableTest extends AbstractTest {
+
+ @Test
+ public void settingValueOnImmutableObjectThrowsException() {
+ try {
+ product355VO.setDescription("Changed");
+ fail("Should have thrown exception");
+ } catch (final DisabledException ex) {
+ assertThat(ex.getAdvisorClass(), classEqualTo(DisabledFacetForPropertyDerivedFromImmutable.class));
+ assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Description"));
+ }
+ }
+
+ @Test
+ public void settingAssociationOnImmutableObjectThrowsException() {
+ try {
+ product355VO.setPlaceOfManufacture(countryUsaDO);
+ fail("Should have thrown exception");
+ } catch (final DisabledException ex) {
+ assertThat(ex.getAdvisorClass(), classEqualTo(DisabledFacetForPropertyDerivedFromImmutable.class));
+ assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Place Of Manufacture"));
+ }
+ }
+
+ @Test
+ public void addingToCollectionOnImmutableObjectThrowsException() {
+ try {
+ product355VO.addToSimilarProducts(product850DO);
+ fail("Should have thrown exception");
+ } catch (final DisabledException ex) {
+ assertThat(ex.getAdvisorClass(), classEqualTo(DisabledFacetForCollectionDerivedFromImmutable.class));
+ assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Similar Products"));
+ }
+ }
+
+ @Test
+ public void removingFromCollectionOnImmutableObjectThrowsException() {
+ product355DO.addToSimilarProducts(product850DO); // TODO: can't setup, throws
+ // ObjectPersistenceException
+ try {
+ product355VO.removeFromSimilarProducts(product850DO);
+ fail("Should have thrown exception");
+ } catch (final DisabledException ex) {
+ assertThat(ex.getAdvisorClass(), classEqualTo(DisabledFacetForCollectionDerivedFromImmutable.class));
+ assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Similar Products"));
+ }
+ }
+
+ @Test
+ public void canInvokingOnImmutableObject() {
+ product355VO.foobar();
+ }
+
+}
Modified: incubator/isis/trunk/viewer/junit/src/test/java/org/apache/isis/viewer/junit/SaveObjectsTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/junit/src/test/java/org/apache/isis/viewer/junit/SaveObjectsTest.java?rev=1098951&r1=1098950&r2=1098951&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/junit/src/test/java/org/apache/isis/viewer/junit/SaveObjectsTest.java (original)
+++ incubator/isis/trunk/viewer/junit/src/test/java/org/apache/isis/viewer/junit/SaveObjectsTest.java Tue May 3 07:53:06 2011
@@ -17,94 +17,89 @@
* under the License.
*/
+package org.apache.isis.viewer.junit;
-package org.apache.isis.viewer.junit;
-
import static org.apache.isis.core.commons.matchers.IsisMatchers.classEqualTo;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
-import org.junit.Test;
-
import org.apache.isis.core.progmodel.facets.object.validate.method.ValidateObjectFacetViaValidateMethod;
import org.apache.isis.progmodel.wrapper.applib.InvalidException;
import org.apache.isis.progmodel.wrapper.applib.WrapperObject;
import org.apache.isis.viewer.junit.sample.domain.Customer;
-
-public class SaveObjectsTest extends AbstractTest {
-
- private WrapperObject asWrapperObject(final Customer proxiedNewCustomer) {
- return (WrapperObject) proxiedNewCustomer;
- }
-
- @Test
- public void invokingSaveThroughProxyMakesTransientObjectPersistent() {
- final Customer newCustomer = getDomainObjectContainer().newTransientInstance(Customer.class);
- assertThat(getDomainObjectContainer().isPersistent(newCustomer),is(false));
- final Customer newCustomerVO = getWrapperFactory().wrap(newCustomer);
- newCustomerVO.setCustomerNumber(123);
- newCustomerVO.setLastName("Smith");
- newCustomerVO.setMandatoryAssociation(countryGbrDO);
- newCustomerVO.setMandatoryValue("foo");
- newCustomerVO.setMaxLengthField("abc");
- newCustomerVO.setRegExCaseInsensitiveField("ABCd");
- newCustomerVO.setRegExCaseSensitiveField("abcd");
- final WrapperObject proxyNewCustomer = asWrapperObject(newCustomerVO);
- proxyNewCustomer.save();
- assertThat(getDomainObjectContainer().isPersistent(newCustomer),
- is(true));
- }
-
- @Test
- public void invokingSaveOnThroughProxyOnAlreadyPersistedObjectJustUpdatesIt() {
- // just to get into valid state
- custJsDO.setCustomerNumber(123);
- custJsDO.setLastName("Smith");
- custJsDO.setMandatoryAssociation(countryGbrDO);
- custJsDO.setMandatoryValue("foo");
- custJsDO.setMaxLengthField("abc");
- custJsDO.setRegExCaseInsensitiveField("ABCd");
- custJsDO.setRegExCaseSensitiveField("abcd");
-
- assertThat(getDomainObjectContainer().isPersistent(custJsDO), is(true));
-
- final WrapperObject newCustomerWO = asWrapperObject(custJsWO);
- newCustomerWO.save();
-
- assertThat(getDomainObjectContainer().isPersistent(custJsDO), is(true));
- }
-
- @Test
- public void whenValidateMethodThenCanVetoSave() {
- final Customer newCustomer = getDomainObjectContainer().newTransientInstance(Customer.class);
-
- // just to get into valid state
- newCustomer.setCustomerNumber(123);
- newCustomer.setLastName("Smith");
- newCustomer.setMandatoryAssociation(countryGbrDO);
- newCustomer.setMandatoryValue("foo");
- newCustomer.setMaxLengthField("abc");
- newCustomer.setRegExCaseInsensitiveField("ABCd");
- newCustomer.setRegExCaseSensitiveField("abcd");
-
- final Customer newCustomerWO = getWrapperFactory().wrap(newCustomer);
- newCustomer.validate = "No shakes";
-
- final WrapperObject newCustomerWrapper = asWrapperObject(newCustomerWO);
- try {
- assertThat(getDomainObjectContainer().isPersistent(newCustomer),
- is(false));
- newCustomerWrapper.save();
- fail("An InvalidImperativelyException should have been thrown");
- } catch (final InvalidException ex) {
-
- assertThat(ex.getAdvisorClass(), classEqualTo(ValidateObjectFacetViaValidateMethod.class));
- assertThat(getDomainObjectContainer().isPersistent(newCustomer),
- is(false)); // not saved
- assertThat(ex.getMessage(), equalTo("No shakes"));
- }
- }
-
-}
+import org.junit.Test;
+
+public class SaveObjectsTest extends AbstractTest {
+
+ private WrapperObject asWrapperObject(final Customer proxiedNewCustomer) {
+ return (WrapperObject) proxiedNewCustomer;
+ }
+
+ @Test
+ public void invokingSaveThroughProxyMakesTransientObjectPersistent() {
+ final Customer newCustomer = getDomainObjectContainer().newTransientInstance(Customer.class);
+ assertThat(getDomainObjectContainer().isPersistent(newCustomer), is(false));
+ final Customer newCustomerVO = getWrapperFactory().wrap(newCustomer);
+ newCustomerVO.setCustomerNumber(123);
+ newCustomerVO.setLastName("Smith");
+ newCustomerVO.setMandatoryAssociation(countryGbrDO);
+ newCustomerVO.setMandatoryValue("foo");
+ newCustomerVO.setMaxLengthField("abc");
+ newCustomerVO.setRegExCaseInsensitiveField("ABCd");
+ newCustomerVO.setRegExCaseSensitiveField("abcd");
+ final WrapperObject proxyNewCustomer = asWrapperObject(newCustomerVO);
+ proxyNewCustomer.save();
+ assertThat(getDomainObjectContainer().isPersistent(newCustomer), is(true));
+ }
+
+ @Test
+ public void invokingSaveOnThroughProxyOnAlreadyPersistedObjectJustUpdatesIt() {
+ // just to get into valid state
+ custJsDO.setCustomerNumber(123);
+ custJsDO.setLastName("Smith");
+ custJsDO.setMandatoryAssociation(countryGbrDO);
+ custJsDO.setMandatoryValue("foo");
+ custJsDO.setMaxLengthField("abc");
+ custJsDO.setRegExCaseInsensitiveField("ABCd");
+ custJsDO.setRegExCaseSensitiveField("abcd");
+
+ assertThat(getDomainObjectContainer().isPersistent(custJsDO), is(true));
+
+ final WrapperObject newCustomerWO = asWrapperObject(custJsWO);
+ newCustomerWO.save();
+
+ assertThat(getDomainObjectContainer().isPersistent(custJsDO), is(true));
+ }
+
+ @Test
+ public void whenValidateMethodThenCanVetoSave() {
+ final Customer newCustomer = getDomainObjectContainer().newTransientInstance(Customer.class);
+
+ // just to get into valid state
+ newCustomer.setCustomerNumber(123);
+ newCustomer.setLastName("Smith");
+ newCustomer.setMandatoryAssociation(countryGbrDO);
+ newCustomer.setMandatoryValue("foo");
+ newCustomer.setMaxLengthField("abc");
+ newCustomer.setRegExCaseInsensitiveField("ABCd");
+ newCustomer.setRegExCaseSensitiveField("abcd");
+
+ final Customer newCustomerWO = getWrapperFactory().wrap(newCustomer);
+ newCustomer.validate = "No shakes";
+
+ final WrapperObject newCustomerWrapper = asWrapperObject(newCustomerWO);
+ try {
+ assertThat(getDomainObjectContainer().isPersistent(newCustomer), is(false));
+ newCustomerWrapper.save();
+ fail("An InvalidImperativelyException should have been thrown");
+ } catch (final InvalidException ex) {
+
+ assertThat(ex.getAdvisorClass(), classEqualTo(ValidateObjectFacetViaValidateMethod.class));
+ assertThat(getDomainObjectContainer().isPersistent(newCustomer), is(false)); // not saved
+ assertThat(ex.getMessage(), equalTo("No shakes"));
+ }
+ }
+
+}
Modified: incubator/isis/trunk/viewer/junit/src/test/java/org/apache/isis/viewer/junit/TitleTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/junit/src/test/java/org/apache/isis/viewer/junit/TitleTest.java?rev=1098951&r1=1098950&r2=1098951&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/junit/src/test/java/org/apache/isis/viewer/junit/TitleTest.java (original)
+++ incubator/isis/trunk/viewer/junit/src/test/java/org/apache/isis/viewer/junit/TitleTest.java Tue May 3 07:53:06 2011
@@ -17,19 +17,17 @@
* under the License.
*/
+package org.apache.isis.viewer.junit;
-package org.apache.isis.viewer.junit;
-
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import org.junit.Test;
-
-
-public class TitleTest extends AbstractTest {
-
- @Test
- public void shouldAppendToDocumentor() {
- assertThat(custJsWO.title(), equalTo("Richard Pawson"));
- }
-}
+
+public class TitleTest extends AbstractTest {
+
+ @Test
+ public void shouldAppendToDocumentor() {
+ assertThat(custJsWO.title(), equalTo("Richard Pawson"));
+ }
+}
Modified: incubator/isis/trunk/viewer/junit/src/test/java/org/apache/isis/viewer/junit/ViewObjectTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/junit/src/test/java/org/apache/isis/viewer/junit/ViewObjectTest.java?rev=1098951&r1=1098950&r2=1098951&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/junit/src/test/java/org/apache/isis/viewer/junit/ViewObjectTest.java (original)
+++ incubator/isis/trunk/viewer/junit/src/test/java/org/apache/isis/viewer/junit/ViewObjectTest.java Tue May 3 07:53:06 2011
@@ -17,9 +17,8 @@
* under the License.
*/
+package org.apache.isis.viewer.junit;
-package org.apache.isis.viewer.junit;
-
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
@@ -27,67 +26,65 @@ import static org.junit.Assert.assertTha
import java.util.List;
-import org.junit.Test;
-
import org.apache.isis.progmodel.wrapper.applib.WrapperObject;
import org.apache.isis.viewer.junit.sample.domain.Country;
import org.apache.isis.viewer.junit.sample.domain.Customer;
-
-
-public class ViewObjectTest extends AbstractTest {
-
- private WrapperObject asWrapperObject() {
- return (WrapperObject) custJsWO;
- }
-
- @Test
- public void canCastViewsToViewObject() {
- @SuppressWarnings("unused")
- final WrapperObject custRpVOAsViewObject = asWrapperObject();
- }
-
- @Test
- public void shouldBeAbleToCreateAView() {
- final Customer custRpVO = getWrapperFactory().wrap(custJsDO);
- assertThat(custRpVO, instanceOf(Customer.class));
- custRpVO.setFirstName("Dick");
-
- assertThat("Dick", equalTo(custRpVO.getFirstName()));
- }
-
- @Test
- public void viewShouldPassesThroughSetterToUnderlyingDomainObject() {
- final Customer custRpVO = getWrapperFactory().wrap(custJsDO);
- custRpVO.setFirstName("Dick");
-
- assertThat("Dick", equalTo(custRpVO.getFirstName()));
- }
-
- @Test
- public void objectIsViewShouldReturnTrueWhenDealingWithView() {
- final Customer custRpVO = getWrapperFactory().wrap(custJsDO);
- assertThat(getWrapperFactory().isWrapper(custRpVO), is(true));
- }
-
- @Test
- public void objectIsViewShouldReturnFalseWhenDealingWithUnderlying() {
- assertThat(getWrapperFactory().isWrapper(custJsDO), is(false));
- }
-
- @Test
- public void collectionInstanceOfViewObjectShouldReturnTrueWhenDealingWithView() {
- custJsDO.addToVisitedCountries(countryGbrDO);
- custJsDO.addToVisitedCountries(countryUsaDO);
- final List<Country> visitedCountries = custJsWO.getVisitedCountries();
- assertThat(visitedCountries instanceof WrapperObject, is(true));
- }
-
- @Test
- public void containsOnViewedCollectionShouldIntercept() {
- custJsDO.addToVisitedCountries(countryGbrDO);
- custJsDO.addToVisitedCountries(countryUsaDO);
- final List<Country> visitedCountries = custJsWO.getVisitedCountries();
- assertThat(visitedCountries.contains(countryGbrDO), is(true));
- }
-
-}
+import org.junit.Test;
+
+public class ViewObjectTest extends AbstractTest {
+
+ private WrapperObject asWrapperObject() {
+ return (WrapperObject) custJsWO;
+ }
+
+ @Test
+ public void canCastViewsToViewObject() {
+ @SuppressWarnings("unused")
+ final WrapperObject custRpVOAsViewObject = asWrapperObject();
+ }
+
+ @Test
+ public void shouldBeAbleToCreateAView() {
+ final Customer custRpVO = getWrapperFactory().wrap(custJsDO);
+ assertThat(custRpVO, instanceOf(Customer.class));
+ custRpVO.setFirstName("Dick");
+
+ assertThat("Dick", equalTo(custRpVO.getFirstName()));
+ }
+
+ @Test
+ public void viewShouldPassesThroughSetterToUnderlyingDomainObject() {
+ final Customer custRpVO = getWrapperFactory().wrap(custJsDO);
+ custRpVO.setFirstName("Dick");
+
+ assertThat("Dick", equalTo(custRpVO.getFirstName()));
+ }
+
+ @Test
+ public void objectIsViewShouldReturnTrueWhenDealingWithView() {
+ final Customer custRpVO = getWrapperFactory().wrap(custJsDO);
+ assertThat(getWrapperFactory().isWrapper(custRpVO), is(true));
+ }
+
+ @Test
+ public void objectIsViewShouldReturnFalseWhenDealingWithUnderlying() {
+ assertThat(getWrapperFactory().isWrapper(custJsDO), is(false));
+ }
+
+ @Test
+ public void collectionInstanceOfViewObjectShouldReturnTrueWhenDealingWithView() {
+ custJsDO.addToVisitedCountries(countryGbrDO);
+ custJsDO.addToVisitedCountries(countryUsaDO);
+ final List<Country> visitedCountries = custJsWO.getVisitedCountries();
+ assertThat(visitedCountries instanceof WrapperObject, is(true));
+ }
+
+ @Test
+ public void containsOnViewedCollectionShouldIntercept() {
+ custJsDO.addToVisitedCountries(countryGbrDO);
+ custJsDO.addToVisitedCountries(countryUsaDO);
+ final List<Country> visitedCountries = custJsWO.getVisitedCountries();
+ assertThat(visitedCountries.contains(countryGbrDO), is(true));
+ }
+
+}
Modified: incubator/isis/trunk/viewer/junit/src/test/java/org/apache/isis/viewer/junit/sample/domain/Country.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/junit/src/test/java/org/apache/isis/viewer/junit/sample/domain/Country.java?rev=1098951&r1=1098950&r2=1098951&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/junit/src/test/java/org/apache/isis/viewer/junit/sample/domain/Country.java (original)
+++ incubator/isis/trunk/viewer/junit/src/test/java/org/apache/isis/viewer/junit/sample/domain/Country.java Tue May 3 07:53:06 2011
@@ -17,7 +17,6 @@
* under the License.
*/
-
package org.apache.isis.viewer.junit.sample.domain;
import java.util.ArrayList;
@@ -31,7 +30,6 @@ import org.apache.isis.applib.annotation
import org.apache.isis.applib.util.TitleBuffer;
import org.apache.log4j.Logger;
-
@Bounded
public class Country extends AbstractDomainObject {
@@ -50,6 +48,7 @@ public class Country extends AbstractDom
t.append(getName());
return t.toString();
}
+
// }}
// {{ Code
@@ -64,6 +63,7 @@ public class Country extends AbstractDom
public void setCode(final String code) {
this.code = code;
}
+
// }}
// {{ Name
@@ -78,6 +78,7 @@ public class Country extends AbstractDom
public void setName(final String name) {
this.name = name;
}
+
// }}
// {{ FavouriteHolidayDestination
@@ -91,6 +92,7 @@ public class Country extends AbstractDom
public void setFavouriteHolidayDestination(final Country favouriteHolidayDestination) {
this.favouriteHolidayDestination = favouriteHolidayDestination;
}
+
// }}
// {{ Colonies
@@ -112,11 +114,13 @@ public class Country extends AbstractDom
public void removeFromColonies(final Country country) {
getColonies().remove(country);
}
+
public String validateAddToColonies;
public String validateAddToColonies(final Country country) {
return validateAddToColonies;
}
+
public String validateRemoveFromColonies;
public String validateRemoveFromColonies(final Country country) {
@@ -141,7 +145,8 @@ public class Country extends AbstractDom
/**
* An action to invoke
*/
- public void foobar() {}
+ public void foobar() {
+ }
// }}
}