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 2013/05/20 14:46:39 UTC
[4/5] ISIS-409: junit viewer moved up to core...
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/MemberModifyTest.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/MemberModifyTest.java b/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/MemberModifyTest.java
deleted file mode 100644
index 0e87673..0000000
--- a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/MemberModifyTest.java
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.junit;
-
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.not;
-import static org.hamcrest.CoreMatchers.nullValue;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.fail;
-
-import java.util.List;
-
-import org.junit.Test;
-
-import org.apache.isis.applib.services.wrapper.InvalidException;
-import org.apache.isis.viewer.junit.sample.domain.Country;
-import org.apache.isis.viewer.junit.sample.domain.Order;
-
-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
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/MemberReadTest.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/MemberReadTest.java b/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/MemberReadTest.java
deleted file mode 100644
index 2b665a6..0000000
--- a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/MemberReadTest.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.junit;
-
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.nullValue;
-import static org.junit.Assert.assertThat;
-
-import java.util.List;
-
-import org.junit.Test;
-
-import org.apache.isis.viewer.junit.sample.domain.Country;
-
-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));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/ObjectImmutableTest.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/ObjectImmutableTest.java b/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/ObjectImmutableTest.java
deleted file mode 100644
index 3abcec6..0000000
--- a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/ObjectImmutableTest.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-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.applib.services.wrapper.DisabledException;
-import org.apache.isis.core.progmodel.facets.collections.disabled.fromimmutable.DisabledFacetForCollectionDerivedFromImmutable;
-import org.apache.isis.core.progmodel.facets.properties.disabled.fromimmutable.DisabledFacetForPropertyDerivedFromImmutable;
-
-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();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/SaveObjectsTest.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/SaveObjectsTest.java b/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/SaveObjectsTest.java
deleted file mode 100644
index 726b051..0000000
--- a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/SaveObjectsTest.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-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.applib.services.wrapper.InvalidException;
-import org.apache.isis.applib.services.wrapper.WrapperObject;
-import org.apache.isis.core.progmodel.facets.object.validate.method.ValidateObjectFacetViaValidateMethod;
-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"));
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/TitleTest.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/TitleTest.java b/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/TitleTest.java
deleted file mode 100644
index 9619faf..0000000
--- a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/TitleTest.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-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"));
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/ViewObjectTest.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/ViewObjectTest.java b/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/ViewObjectTest.java
deleted file mode 100644
index dcc4593..0000000
--- a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/ViewObjectTest.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.junit;
-
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-import java.util.List;
-
-import org.junit.Test;
-
-import org.apache.isis.applib.services.wrapper.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));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/sample/domain/Country.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/sample/domain/Country.java b/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/sample/domain/Country.java
deleted file mode 100644
index 6dd6ef4..0000000
--- a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/sample/domain/Country.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.junit.sample.domain;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.log4j.Logger;
-
-import org.apache.isis.applib.AbstractDomainObject;
-import org.apache.isis.applib.annotation.Bounded;
-import org.apache.isis.applib.annotation.MaxLength;
-import org.apache.isis.applib.annotation.Optional;
-import org.apache.isis.applib.annotation.TypicalLength;
-import org.apache.isis.applib.util.TitleBuffer;
-
-@Bounded
-public class Country extends AbstractDomainObject {
-
- // {{ Logger
- @SuppressWarnings("unused")
- private final static Logger LOGGER = Logger.getLogger(Country.class);
-
- // }}
-
- // {{ Identification Methods
- /**
- * Defines the title that will be displayed on the user interface in order
- * to identity this object.
- */
- public String title() {
- final TitleBuffer t = new TitleBuffer();
- t.append(getName());
- return t.toString();
- }
-
- // }}
-
- // {{ Code
- private String code;
-
- @TypicalLength(3)
- @MaxLength(3)
- public String getCode() {
- return this.code;
- }
-
- public void setCode(final String code) {
- this.code = code;
- }
-
- // }}
-
- // {{ Name
- private String name;
-
- @TypicalLength(50)
- @MaxLength(255)
- public String getName() {
- return this.name;
- }
-
- public void setName(final String name) {
- this.name = name;
- }
-
- // }}
-
- // {{ FavouriteHolidayDestination
- private Country favouriteHolidayDestination;
-
- @Optional
- public Country getFavouriteHolidayDestination() {
- return favouriteHolidayDestination;
- }
-
- public void setFavouriteHolidayDestination(final Country favouriteHolidayDestination) {
- this.favouriteHolidayDestination = favouriteHolidayDestination;
- }
-
- // }}
-
- // {{ Colonies
- private List<Country> colonies = new ArrayList<Country>();
-
- public List<Country> getColonies() {
- return this.colonies;
- }
-
- @SuppressWarnings("unused")
- private void setColonies(final List<Country> colonies) {
- this.colonies = colonies;
- }
-
- public void addToColonies(final Country country) {
- getColonies().add(country);
- }
-
- 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) {
- return validateRemoveFromColonies;
- }
-
- public String disableColonies;
-
- public String disableColonies() {
- return this.disableColonies;
- }
-
- public boolean hideColonies;
-
- public boolean hideColonies() {
- return this.hideColonies;
- }
-
- // }}
-
- // {{
- /**
- * An action to invoke
- */
- public void foobar() {
- }
- // }}
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/sample/domain/Customer.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/sample/domain/Customer.java b/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/sample/domain/Customer.java
deleted file mode 100644
index e5e477e..0000000
--- a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/sample/domain/Customer.java
+++ /dev/null
@@ -1,777 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.junit.sample.domain;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-import org.apache.isis.applib.AbstractDomainObject;
-import org.apache.isis.applib.annotation.DescribedAs;
-import org.apache.isis.applib.annotation.Disabled;
-import org.apache.isis.applib.annotation.Hidden;
-import org.apache.isis.applib.annotation.MaxLength;
-import org.apache.isis.applib.annotation.Named;
-import org.apache.isis.applib.annotation.Optional;
-import org.apache.isis.applib.annotation.RegEx;
-import org.apache.isis.applib.annotation.TypicalLength;
-import org.apache.isis.applib.annotation.When;
-import org.apache.isis.applib.clock.Clock;
-import org.apache.isis.applib.security.UserMemento;
-import org.apache.isis.applib.util.TitleBuffer;
-
-public class Customer extends AbstractDomainObject {
-
- // {{ Identification Methods
- /**
- * Defines the title that will be displayed on the user interface in order
- * to identity this object.
- */
- public String title() {
- final TitleBuffer t = new TitleBuffer();
- t.append(getFirstName()).append(getLastName());
- return t.toString();
- }
-
- // }}
-
- // {{ FirstName
- private String firstName;
-
- @DescribedAs("Given or christian name")
- @TypicalLength(20)
- @MaxLength(100)
- @Optional
- public String getFirstName() {
- return this.firstName;
- }
-
- public void setFirstName(final String firstName) {
- this.firstName = firstName;
- }
-
- public boolean modifyFirstNameCalled = false;
-
- public void modifyFirstName(final String firstName) {
- setFirstName(firstName);
- this.modifyFirstNameCalled = true;
- }
-
- public boolean clearFirstNameCalled = false;
-
- public void clearFirstName() {
- setFirstName(null);
- this.clearFirstNameCalled = true;
- }
-
- public String validateFirstName;
- public String validateFirstNameExpectedArg;
-
- public String validateFirstName(final String firstName) {
- if (validateFirstNameExpectedArg != null && !validateFirstNameExpectedArg.equals(firstName)) {
- return "argument provided by XAT framework was incorrect";
- }
- return validateFirstName;
- }
-
- public String disableFirstName;
-
- public String disableFirstName() {
- return this.disableFirstName;
- }
-
- public boolean hideFirstName;
-
- public boolean hideFirstName() {
- return this.hideFirstName;
- }
-
- // }}
-
- // {{ CountryOfBirth
- private Country countryOfBirth;
-
- @Optional
- public Country getCountryOfBirth() {
- return countryOfBirth;
- }
-
- public void setCountryOfBirth(final Country countryOfBirth) {
- this.countryOfBirth = countryOfBirth;
- }
-
- public boolean modifyCountryOfBirthCalled = false;
-
- public void modifyCountryOfBirth(final Country countryOfBirth) {
- setCountryOfBirth(countryOfBirth);
- this.modifyCountryOfBirthCalled = true;
- }
-
- public boolean clearCountryOfBirthCalled = false;
-
- public void clearCountryOfBirth() {
- setCountryOfBirth(null);
- this.clearCountryOfBirthCalled = true;
- }
-
- public String validateCountryOfBirth;
-
- public String validateCountryOfBirth(final Country countryOfBirth) {
- return validateCountryOfBirth;
- }
-
- public String disableCountryOfBirth;
-
- public String disableCountryOfBirth() {
- return this.disableCountryOfBirth;
- }
-
- public boolean hideCountryOfBirth;
-
- public boolean hideCountryOfBirth() {
- return this.hideCountryOfBirth;
- }
-
- // }}
-
- // {{ VisitedCountries
- private List<Country> visitedCountries = new ArrayList<Country>();
-
- public List<Country> getVisitedCountries() {
- return this.visitedCountries;
- }
-
- @SuppressWarnings("unused")
- private void setVisitedCountries(final List<Country> visitedCountries) {
- this.visitedCountries = visitedCountries;
- }
-
- public void addToVisitedCountries(final Country country) {
- getVisitedCountries().add(country);
- }
-
- public void removeFromVisitedCountries(final Country country) {
- getVisitedCountries().remove(country);
- }
-
- public String validateAddToVisitedCountries;
-
- public String validateAddToVisitedCountries(final Country country) {
- return validateAddToVisitedCountries;
- }
-
- public String validateRemoveFromVisitedCountries;
-
- public String validateRemoveFromVisitedCountries(final Country country) {
- return validateRemoveFromVisitedCountries;
- }
-
- public String disableVisitedCountries;
-
- public String disableVisitedCountries() {
- return this.disableVisitedCountries;
- }
-
- public boolean hideVisitedCountries;
-
- public boolean hideVisitedCountries() {
- return this.hideVisitedCountries;
- }
-
- // }}
-
- // {{ AlwaysDisabledValue
- private String alwaysDisabledValue;
-
- @Disabled(when = When.ALWAYS)
- public String getAlwaysDisabledValue() {
- return this.alwaysDisabledValue;
- }
-
- public void setAlwaysDisabledValue(final String alwaysDisabled) {
- this.alwaysDisabledValue = alwaysDisabled;
- }
-
- // }}
-
- // {{ AlwaysDisabledAssociation
- private Country alwaysDisabledAssociation;
-
- @Disabled(when = When.ALWAYS)
- public Country getAlwaysDisabledAssociation() {
- return this.alwaysDisabledAssociation;
- }
-
- public void setAlwaysDisabledAssociation(final Country alwaysDisabled) {
- this.alwaysDisabledAssociation = alwaysDisabled;
- }
-
- // }}
-
- // {{ AlwaysDisabledCollection
- private List<Country> alwaysDisabledCollection = new ArrayList<Country>();
-
- @Disabled(when = When.ALWAYS)
- public List<Country> getAlwaysDisabledCollection() {
- return this.alwaysDisabledCollection;
- }
-
- @SuppressWarnings("unused")
- private void setAlwaysDisabledCollection(final List<Country> alwaysDisabledCollection) {
- this.alwaysDisabledCollection = alwaysDisabledCollection;
- }
-
- public void addToAlwaysDisabledCollection(final Country country) {
- getAlwaysDisabledCollection().add(country);
- }
-
- public void removeFromAlwaysDisabledCollection(final Country country) {
- getAlwaysDisabledCollection().remove(country);
- }
-
- // }}
-
- // {{ AlwaysDisabledAction
- @Disabled(when = When.ALWAYS)
- public void alwaysDisabledAction() {
- }
-
- // }}
-
- // {{ SessionDisabledValue
- private String sessionDisabledValue;
-
- public String getSessionDisabledValue() {
- return this.sessionDisabledValue;
- }
-
- public void setSessionDisabledValue(final String sessionDisabled) {
- this.sessionDisabledValue = sessionDisabled;
- }
-
- public static String disableSessionDisabledValue(final UserMemento user) {
- return "disabled for this user";
- }
-
- // }}
-
- // {{ SessionDisabledAssociation
- private Country sessionDisabledAssociation;
-
- public Country getSessionDisabledAssociation() {
- return this.sessionDisabledAssociation;
- }
-
- public void setSessionDisabledAssociation(final Country sessionDisabled) {
- this.sessionDisabledAssociation = sessionDisabled;
- }
-
- public static String disableSessionDisabledAssociation(final UserMemento user) {
- return "disabled for this user";
- }
-
- // }}
-
- // {{ SessionDisabledCollection
- private List<Country> sessionDisabledCollection = new ArrayList<Country>();
-
- public List<Country> getSessionDisabledCollection() {
- return this.sessionDisabledCollection;
- }
-
- @SuppressWarnings("unused")
- private void setSessionDisabledCollection(final List<Country> sessionDisabledCollection) {
- this.sessionDisabledCollection = sessionDisabledCollection;
- }
-
- public void addToSessionDisabledCollection(final Country country) {
- getSessionDisabledCollection().add(country);
- }
-
- public void removeFromSessionDisabledCollection(final Country country) {
- getSessionDisabledCollection().remove(country);
- }
-
- public static String disableSessionDisabledCollection(final UserMemento user) {
- return "disabled for this user";
- }
-
- // }}
-
- // {{ SessionDisabledAction
- public void sessionDisabledAction() {
- }
-
- public static String disableSessionDisabledAction(final UserMemento user) {
- return "disabled for this user";
- }
-
- // }}
-
- // {{ AlwaysHiddenValue
- private String alwaysHiddenValue;
-
- @Hidden(when=When.ALWAYS)
- public String getAlwaysHiddenValue() {
- return this.alwaysHiddenValue;
- }
-
- public void setAlwaysHiddenValue(final String alwaysHidden) {
- this.alwaysHiddenValue = alwaysHidden;
- }
-
- // }}
-
- // {{ AlwaysHiddenAssociation
- private Country alwaysHiddenAssociation;
-
- @Hidden(when=When.ALWAYS)
- public Country getAlwaysHiddenAssociation() {
- return this.alwaysHiddenAssociation;
- }
-
- public void setAlwaysHiddenAssociation(final Country alwaysHidden) {
- this.alwaysHiddenAssociation = alwaysHidden;
- }
-
- // }}
-
- // {{ AlwaysHiddenCollection
- private List<Country> alwaysHiddenCollection = new ArrayList<Country>();
-
- @Hidden(when=When.ALWAYS)
- public List<Country> getAlwaysHiddenCollection() {
- return this.alwaysHiddenCollection;
- }
-
- @SuppressWarnings("unused")
- private void setAlwaysHiddenCollection(final List<Country> alwaysHiddenCollection) {
- this.alwaysHiddenCollection = alwaysHiddenCollection;
- }
-
- public void addToAlwaysHiddenCollection(final Country country) {
- getAlwaysHiddenCollection().add(country);
- }
-
- public void removeFromAlwaysHiddenCollection(final Country country) {
- getAlwaysHiddenCollection().remove(country);
- }
-
- // }}
-
- // {{ SessionDisabledAction
- @Hidden(when=When.ALWAYS)
- public void alwaysHiddenAction() {
- }
-
- // }}
-
- // {{ SessionHiddenValue
- private String sessionHiddenValue;
-
- public String getSessionHiddenValue() {
- return this.sessionHiddenValue;
- }
-
- public void setSessionHiddenValue(final String sessionHidden) {
- this.sessionHiddenValue = sessionHidden;
- }
-
- public static boolean hideSessionHiddenValue(final UserMemento user) {
- return true;
- }
-
- // }}
-
- // {{ SessionHiddenAssociation
- private Country sessionHiddenAssociation;
-
- public Country getSessionHiddenAssociation() {
- return this.sessionHiddenAssociation;
- }
-
- public void setSessionHiddenAssociation(final Country sessionHidden) {
- this.sessionHiddenAssociation = sessionHidden;
- }
-
- public static boolean hideSessionHiddenAssociation(final UserMemento user) {
- return true;
- }
-
- // }}
-
- // {{ SessionHiddenCollection
- private List<Country> sessionHiddenCollection = new ArrayList<Country>();
-
- public List<Country> getSessionHiddenCollection() {
- return this.sessionHiddenCollection;
- }
-
- @SuppressWarnings("unused")
- private void setSessionHiddenCollection(final List<Country> sessionHiddenCollection) {
- this.sessionHiddenCollection = sessionHiddenCollection;
- }
-
- public void addToSessionHiddenCollection(final Country country) {
- getSessionHiddenCollection().add(country);
- }
-
- public void removeFromSessionHiddenCollection(final Country country) {
- getSessionHiddenCollection().remove(country);
- }
-
- public static boolean hideSessionHiddenCollection(final UserMemento user) {
- return true;
- }
-
- // }}
-
- // {{ SessionHiddenAction
- public void sessionHiddenAction() {
- }
-
- public static boolean hideSessionHiddenAction(final UserMemento user) {
- return true;
- }
-
- // }}
-
- // {{ Mandatory
- private String mandatoryValue;
-
- public String getMandatoryValue() {
- return this.mandatoryValue;
- }
-
- public void setMandatoryValue(final String mandatory) {
- this.mandatoryValue = mandatory;
- }
-
- // }}
-
- // {{ Mandatory
- private Country mandatoryAssociation;
-
- public Country getMandatoryAssociation() {
- return this.mandatoryAssociation;
- }
-
- public void setMandatoryAssociation(final Country mandatory) {
- this.mandatoryAssociation = mandatory;
- }
-
- // }}
-
- // {{ Optional
- private String optionalValue;
-
- @Optional
- public String getOptionalValue() {
- return this.optionalValue;
- }
-
- public void setOptionalValue(final String optional) {
- this.optionalValue = optional;
- }
-
- // }}
-
- // {{ OptionalAssociation
- private Country optionalAssociation;
-
- @Optional
- public Country getOptionalAssociation() {
- return this.optionalAssociation;
- }
-
- public void setOptionalAssociation(final Country optional) {
- this.optionalAssociation = optional;
- }
-
- // }}
-
- // {{ OptionalCollection
- private List<Country> optionalCollection = new ArrayList<Country>();
-
- @Optional
- public List<Country> getOptionalCollection() {
- return this.optionalCollection;
- }
-
- @SuppressWarnings("unused")
- private void setOptionalCollection(final List<Country> optionalCollection) {
- this.optionalCollection = optionalCollection;
- }
-
- public void addToOptionalCollection(final Country country) {
- getOptionalCollection().add(country);
- }
-
- public void removeFromOptionalCollection(final Country country) {
- getOptionalCollection().remove(country);
- }
-
- // }}
-
- // {{ MaxLength
- private String maxLengthField;
-
- @MaxLength(10)
- public String getMaxLengthField() {
- return this.maxLengthField;
- }
-
- public void setMaxLengthField(final String maxLength) {
- this.maxLengthField = maxLength;
- }
-
- // }}
-
- // {{ RegExCaseSensitive
- private String regExCaseSensitiveField;
-
- @RegEx(validation = "abc.+", caseSensitive = true)
- public String getRegExCaseSensitiveField() {
- return this.regExCaseSensitiveField;
- }
-
- public void setRegExCaseSensitiveField(final String regEx) {
- this.regExCaseSensitiveField = regEx;
- }
-
- // }}
-
- // {{ RegExCaseInsensitive
- private String regExCaseInsensitiveField;
-
- @RegEx(validation = "abc.+", caseSensitive = false)
- public String getRegExCaseInsensitiveField() {
- return this.regExCaseInsensitiveField;
- }
-
- public void setRegExCaseInsensitiveField(final String regExCaseInsensitive) {
- this.regExCaseInsensitiveField = regExCaseInsensitive;
- }
-
- // }}
-
- // {{ LastName
- private String lastName;
-
- @DescribedAs("Family name or surname")
- @MaxLength(100)
- @TypicalLength(30)
- @Named("Surname")
- public String getLastName() {
- return this.lastName;
- }
-
- public void setLastName(final String lastName) {
- this.lastName = lastName;
- }
-
- public void modifyLastName(final String lastName) {
- this.lastName = lastName;
- }
-
- // }}
-
- // {{ CustomerNumber
- private Integer customerNumber;
-
- @Disabled(when = When.ONCE_PERSISTED)
- public Integer getCustomerNumber() {
- return this.customerNumber;
- }
-
- public void setCustomerNumber(final Integer customerNumber) {
- this.customerNumber = customerNumber;
- }
-
- public String validateCustomerNumber(final Integer customerNumber) {
- return null;
- }
-
- // }}
-
- // {{ Orders
- private List<Order> orders = new ArrayList<Order>();
-
- public List<Order> getOrders() {
- return this.orders;
- }
-
- @SuppressWarnings("unused")
- private void setOrders(final List<Order> orders) {
- this.orders = orders;
- }
-
- public void addToOrders(final Order order) {
- getOrders().add(order);
- }
-
- public void removeFromOrders(final Order order) {
- getOrders().remove(order);
- }
-
- // }}
-
- // {{ LastOrder
- private Order lastOrder;
-
- @Disabled
- public Order getLastOrder() {
- return this.lastOrder;
- }
-
- public void setLastOrder(final Order lastOrder) {
- this.lastOrder = lastOrder;
- }
-
- public void modifyLastOrder(final Order lastOrder) {
- setLastOrder(lastOrder);
- }
-
- public void clearLastOrder() {
- setLastOrder(null);
- }
-
- // }}
-
- // {{ PlaceOrder
- public void placeOrder(final Product p, @Named("Quantity") final Integer quantity) {
- final Order order = getContainer().newTransientInstance(Order.class);
- order.modifyCustomer(this);
- order.modifyProduct(p);
- order.setOrderDate(new Date(Clock.getTime()));
- order.setQuantity(quantity);
- addToOrders(order);
- modifyLastOrder(order);
- order.makePersistent();
- }
-
- public String validatePlaceOrder;
-
- public String validatePlaceOrder(final Product p, final Integer quantity) {
- return validatePlaceOrder;
- }
-
- public String disablePlaceOrder;
-
- public String disablePlaceOrder(final Product p, final Integer quantity) {
- return disablePlaceOrder;
- }
-
- public boolean hidePlaceOrder;
-
- public boolean hidePlaceOrder() {
- return hidePlaceOrder;
- }
-
- public Object[] defaultPlaceOrder() {
- Product lastProductOrdered = null;
- if (getLastOrder() != null) {
- lastProductOrdered = getLastOrder().getProduct();
- }
- return new Object[] { lastProductOrdered, new Integer(1) };
- }
-
- // }}
-
- // {{ MoreOrders
- private List<Order> moreOrders = new ArrayList<Order>();
-
- @Disabled
- public List<Order> getMoreOrders() {
- return this.moreOrders;
- }
-
- @SuppressWarnings("unused")
- private void setMoreOrders(final List<Order> moreOrders) {
- this.moreOrders = moreOrders;
- }
-
- public void addToMoreOrders(final Order order) {
- getMoreOrders().add(order);
- }
-
- public void removeFromMoreOrders(final Order order) {
- getMoreOrders().remove(order);
- }
-
- // }}
-
- public String validate;
- public boolean validateCalled = false;
-
- public String validate() {
- validateCalled = true;
- return validate;
- }
-
- public Long actionWithOptionalValueParameterArgument = Long.MAX_VALUE;
-
- public void actionWithOptionalValueParameter(@Optional @Named("Amount") final Long val) {
- actionWithOptionalValueParameterArgument = val;
- }
-
- public Long actionWithMandatoryValueParameterArgument = Long.MAX_VALUE;
-
- public void actionWithMandatoryValueParameter(@Named("Amount") final Long val) {
- actionWithMandatoryValueParameterArgument = val;
- }
-
- public Product actionWithMandatoryReferenceParameterArgument = new Product();
-
- public void actionWithMandatoryReferenceParameter(final Product product) {
- actionWithMandatoryReferenceParameterArgument = product;
- }
-
- public Product actionWithOptionalReferenceParameterArgument = new Product();
-
- public void actionWithOptionalReferenceParameter(@Optional final Product product) {
- actionWithOptionalReferenceParameterArgument = product;
- }
-
- public String actionWithOptionalStringParameterArgument = "original value";
-
- public void actionWithOptionalStringParameter(@Optional @Named("Amount") final String val) {
- actionWithOptionalStringParameterArgument = val;
- }
-
- public String actionWithMandatoryStringParameterArgument = "original value";
-
- public void actionWithMandatoryStringParameter(@Named("Amount") final String val) {
- actionWithMandatoryStringParameterArgument = val;
- }
-
- public String actionWithMaxLengthStringParameterArgument = "1234";
-
- public void actionWithMaxLengthStringParameter(@Named("Amount") @MaxLength(4) final String val) {
- actionWithMaxLengthStringParameterArgument = val;
- }
-
- public String actionWithRegExStringParameterArgument = "1234";
-
- public void actionWithRegExStringParameter(@Named("Amount") @RegEx(validation = "[0-9]{4}") final String val) {
- actionWithRegExStringParameterArgument = val;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/sample/domain/Order.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/sample/domain/Order.java b/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/sample/domain/Order.java
deleted file mode 100644
index 7b58392..0000000
--- a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/sample/domain/Order.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.junit.sample.domain;
-
-import java.util.Date;
-
-import org.apache.log4j.Logger;
-
-import org.apache.isis.applib.AbstractDomainObject;
-import org.apache.isis.applib.annotation.Disabled;
-import org.apache.isis.applib.util.TitleBuffer;
-
-public class Order extends AbstractDomainObject {
-
- // use ctrl+space to bring up the NO templates.
- // if you do not wish to subclass AbstractDomainObject,
- // then use the "injc - Inject Container" template.
-
- // also, use CoffeeBytes code folding with
- // user-defined regions of {{ and }}
-
- // {{ Logger
- @SuppressWarnings("unused")
- private final static Logger LOGGER = Logger.getLogger(Order.class);
-
- // }}
-
- // {{ Identification Methods
- /**
- * Defines the title that will be displayed on the user interface in order
- * to identity this object.
- */
- public String title() {
- final TitleBuffer t = new TitleBuffer();
- // null guard because NOF may call title while still setting
- // up the object
- final Product product = getProduct();
- if (product != null) {
- t.append(product.getCode());
- } else {
- t.append("???");
- }
- t.append("x", getQuantity());
- return t.toString();
- }
-
- // }}
-
- // {{ OrderDate
- private Date orderDate;
-
- @Disabled
- public Date getOrderDate() {
- return this.orderDate;
- }
-
- public void setOrderDate(final Date orderDate) {
- this.orderDate = orderDate;
- }
-
- // }}
-
- // {{ Quantity
- private Integer quantity;
-
- public Integer getQuantity() {
- return this.quantity;
- }
-
- public void setQuantity(final Integer quantity) {
- this.quantity = quantity;
- }
-
- public String validateQuantity(final Integer quantity) {
- return quantity.intValue() <= 0 ? "Quantity must be a positive value" : null;
- }
-
- public String disableQuantity() {
- return isPersistent() ? "Already saved" : null;
- }
-
- public Integer defaultQuantity() {
- return new Integer(1);
- }
-
- // }}
-
- // {{ Customer
- private Customer customer;
-
- @Disabled
- public Customer getCustomer() {
- return this.customer;
- }
-
- public void setCustomer(final Customer customer) {
- this.customer = customer;
- }
-
- public void modifyCustomer(final Customer customer) {
- setCustomer(customer);
- }
-
- public void clearCustomer() {
- setCustomer(null);
- }
-
- // }}
-
- // {{ Product
- private Product product;
-
- @Disabled
- public Product getProduct() {
- return this.product;
- }
-
- public void setProduct(final Product product) {
- this.product = product;
- }
-
- /**
- * Capture price from product at time the order is taken.
- *
- * @param product
- */
- public void modifyProduct(final Product product) {
- setProduct(product);
- setPrice(product.getPrice());
- }
-
- /**
- * Never called.
- *
- * @param product
- */
- public void clearProduct() {
- setProduct(null);
- }
-
- // }}
-
- // {{ Price
- private Double price;
-
- @Disabled
- public Double getPrice() {
- return this.price;
- }
-
- public void setPrice(final Double price) {
- this.price = price;
- }
-
- // }}
-
- // {{ makePersistent
- /**
- * Raise visibility so can be invoked by other classes.
- */
- @Override
- public void makePersistent() {
- persist(this);
- }
- // }}
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/sample/domain/Product.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/sample/domain/Product.java b/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/sample/domain/Product.java
deleted file mode 100644
index c77ae99..0000000
--- a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/sample/domain/Product.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.junit.sample.domain;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.log4j.Logger;
-
-import org.apache.isis.applib.AbstractDomainObject;
-import org.apache.isis.applib.annotation.Disabled;
-import org.apache.isis.applib.annotation.Immutable;
-import org.apache.isis.applib.annotation.MaxLength;
-import org.apache.isis.applib.annotation.Optional;
-import org.apache.isis.applib.annotation.TypicalLength;
-import org.apache.isis.applib.annotation.When;
-import org.apache.isis.applib.util.TitleBuffer;
-
-@Immutable
-public class Product extends AbstractDomainObject {
-
- // use ctrl+space to bring up the NO templates.
- // if you do not wish to subclass AbstractDomainObject,
- // then use the "injc - Inject Container" template.
-
- // also, use CoffeeBytes code folding with
- // user-defined regions of {{ and }}
-
- // {{ Logger
- @SuppressWarnings("unused")
- private final static Logger LOGGER = Logger.getLogger(Product.class);
-
- // }}
-
- // {{ Identification Methods
- /**
- * Defines the title that will be displayed on the user interface in order
- * to identity this object.
- */
- public String title() {
- final TitleBuffer t = new TitleBuffer();
- t.append(getCode());
- t.append(":", getDescription());
- return t.toString();
- }
-
- // }}
-
- // {{ Code
- private String code;
-
- @TypicalLength(9)
- @MaxLength(9)
- @Disabled(when = When.ONCE_PERSISTED)
- public String getCode() {
- return this.code;
- }
-
- public void setCode(final String code) {
- this.code = code;
- }
-
- // }}
-
- // {{ Description
- private String description;
-
- @TypicalLength(50)
- @MaxLength(255)
- public String getDescription() {
- return this.description;
- }
-
- public void setDescription(final String description) {
- this.description = description;
- }
-
- // }}
-
- // {{ PlaceOfManufacture
- private Country placeOfManufacture;
-
- @Optional
- public Country getPlaceOfManufacture() {
- return placeOfManufacture;
- }
-
- public void setPlaceOfManufacture(final Country placeOfManufacture) {
- this.placeOfManufacture = placeOfManufacture;
- }
-
- // }}
-
- // {{ Price
- private Double price;
-
- public Double getPrice() {
- return this.price;
- }
-
- public void setPrice(final Double price) {
- this.price = price;
- }
-
- public String validatePrice(final Double price) {
- if (price.doubleValue() <= 0) {
- return "Price must be positive";
- }
- return null;
- }
-
- // }}
-
- // {{ SimilarProducts
- private List<Product> similarProducts = new ArrayList<Product>();
-
- public List<Product> getSimilarProducts() {
- return this.similarProducts;
- }
-
- @SuppressWarnings("unused")
- private void setSimilarProducts(final List<Product> similarProducts) {
- this.similarProducts = similarProducts;
- }
-
- public void addToSimilarProducts(final Product country) {
- getSimilarProducts().add(country);
- }
-
- public void removeFromSimilarProducts(final Product country) {
- getSimilarProducts().remove(country);
- }
-
- public String validateAddToSimilarProducts;
-
- public String validateAddToSimilarProducts(final Product country) {
- return validateAddToSimilarProducts;
- }
-
- public String validateRemoveFromSimilarProducts;
-
- public String validateRemoveFromSimilarProducts(final Product country) {
- return validateRemoveFromSimilarProducts;
- }
-
- public String disableSimilarProducts;
-
- public String disableSimilarProducts() {
- return this.disableSimilarProducts;
- }
-
- public boolean hideSimilarProducts;
-
- public boolean hideSimilarProducts() {
- return this.hideSimilarProducts;
- }
-
- // }}
-
- // {{
- /**
- * An action to invoke
- */
- public void foobar() {
- }
- // }}
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/sample/fixtures/CountriesFixture.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/sample/fixtures/CountriesFixture.java b/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/sample/fixtures/CountriesFixture.java
deleted file mode 100644
index 3ced8a1..0000000
--- a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/sample/fixtures/CountriesFixture.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.junit.sample.fixtures;
-
-import org.apache.log4j.Logger;
-
-import org.apache.isis.applib.fixtures.AbstractFixture;
-import org.apache.isis.viewer.junit.sample.service.CountryRepository;
-
-public class CountriesFixture extends AbstractFixture {
-
- // {{ Logger
- private final static Logger LOGGER = Logger.getLogger(CountriesFixture.class);
-
- public Logger getLOGGER() {
- return LOGGER;
- }
-
- // }}
-
- @Override
- public void install() {
- getLOGGER().debug("installing");
- getCountryRepository().newCountry("AUS", "Australia");
- getCountryRepository().newCountry("GBR", "United Kingdom of Great Britain & N. Ireland");
- getCountryRepository().newCountry("USA", "United States of America");
- }
-
- // {{ Injected: CountryRepository
- private CountryRepository countryRepository;
-
- /**
- * This field is not persisted, nor displayed to the user.
- */
- protected CountryRepository getCountryRepository() {
- return this.countryRepository;
- }
-
- /**
- * Injected by the application container.
- */
- public void setCountryRepository(final CountryRepository countryRepository) {
- this.countryRepository = countryRepository;
- }
- // }}
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/sample/fixtures/CustomerOrdersFixture.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/sample/fixtures/CustomerOrdersFixture.java b/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/sample/fixtures/CustomerOrdersFixture.java
deleted file mode 100644
index 791ae74..0000000
--- a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/sample/fixtures/CustomerOrdersFixture.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.junit.sample.fixtures;
-
-import org.apache.log4j.Logger;
-
-import org.apache.isis.applib.fixtures.AbstractFixture;
-import org.apache.isis.viewer.junit.sample.domain.Customer;
-import org.apache.isis.viewer.junit.sample.domain.Product;
-import org.apache.isis.viewer.junit.sample.service.CustomerRepository;
-import org.apache.isis.viewer.junit.sample.service.ProductRepository;
-
-public class CustomerOrdersFixture extends AbstractFixture {
-
- // use ctrl+space to bring up the NO templates.
-
- // also, use CoffeeBytes code folding with
- // user-defined regions of {{ and }}
-
- // {{ Logger
- private final static Logger LOGGER = Logger.getLogger(CustomerOrdersFixture.class);
-
- public Logger getLOGGER() {
- return LOGGER;
- }
-
- // }}
-
- @Override
- public void install() {
- getLOGGER().debug("installing");
- final Customer richard = getCustomerRepository().findByName("Pawson");
- final Product foldingTable = getProductRepository().findByCode("820-72721");
- final Product foldingChair = getProductRepository().findByCode("820-72725");
- final Product waspCatcher = getProductRepository().findByCode("850-18003");
- final Product coolbox = getProductRepository().findByCode("845-01020");
-
- setDate(2007, 4, 11);
- setTime(10, 15);
- richard.placeOrder(foldingTable, 1);
- setDate(2007, 4, 12);
- setTime(9, 35);
- richard.placeOrder(foldingChair, 6);
- setDate(2007, 4, 13);
- setTime(14, 20);
- richard.placeOrder(waspCatcher, 1);
- setDate(2007, 4, 14);
- setTime(11, 10);
- richard.placeOrder(coolbox, 1);
- }
-
- // {{ Injected: CustomerRepository
- private CustomerRepository customerRepository;
-
- /**
- * This field is not persisted, nor displayed to the user.
- */
- protected CustomerRepository getCustomerRepository() {
- return this.customerRepository;
- }
-
- /**
- * Injected by the application container.
- */
- public void setCustomerRepository(final CustomerRepository customerRepository) {
- this.customerRepository = customerRepository;
- }
-
- // }}
-
- // {{ Injected: ProductRepository
- private ProductRepository productRepository;
-
- /**
- * This field is not persisted, nor displayed to the user.
- */
- protected ProductRepository getProductRepository() {
- return this.productRepository;
- }
-
- /**
- * Injected by the application container.
- */
- public void setProductRepository(final ProductRepository productRepository) {
- this.productRepository = productRepository;
- }
- // }}
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/sample/fixtures/CustomersFixture.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/sample/fixtures/CustomersFixture.java b/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/sample/fixtures/CustomersFixture.java
deleted file mode 100644
index e0511a7..0000000
--- a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/sample/fixtures/CustomersFixture.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.junit.sample.fixtures;
-
-import org.apache.log4j.Logger;
-
-import org.apache.isis.applib.fixtures.AbstractFixture;
-import org.apache.isis.viewer.junit.sample.domain.Country;
-import org.apache.isis.viewer.junit.sample.service.CountryRepository;
-import org.apache.isis.viewer.junit.sample.service.CustomerRepository;
-
-public class CustomersFixture extends AbstractFixture {
-
- // {{ Logger
- private final static Logger LOGGER = Logger.getLogger(CustomersFixture.class);
-
- public Logger getLOGGER() {
- return LOGGER;
- }
-
- // }}
-
- @Override
- public void install() {
- getLOGGER().debug("installing");
- final Country countryGBR = getCountryRepository().findByCode("GBR");
- getCustomerRepository().newCustomer("Richard", "Pawson", 1, countryGBR);
- getCustomerRepository().newCustomer("Robert", "Matthews", 2, countryGBR);
- getCustomerRepository().newCustomer("Dan", "Haywood", 3, countryGBR);
- getCustomerRepository().newCustomer("Stef", "Cascarini", 4, countryGBR);
- getCustomerRepository().newCustomer("Dave", "Slaughter", 5, countryGBR);
- }
-
- // {{ Injected: CustomerRepository
- private CustomerRepository customerRepository;
-
- /**
- * This field is not persisted, nor displayed to the user.
- */
- protected CustomerRepository getCustomerRepository() {
- return this.customerRepository;
- }
-
- /**
- * Injected by the application container.
- */
- public void setCustomerRepository(final CustomerRepository customerRepository) {
- this.customerRepository = customerRepository;
- }
-
- // }}
-
- // {{ Injected: CountryRepository
- private CountryRepository countryRepository;
-
- /**
- * This field is not persisted, nor displayed to the user.
- */
- protected CountryRepository getCountryRepository() {
- return this.countryRepository;
- }
-
- /**
- * Injected by the application container.
- */
- public void setCountryRepository(final CountryRepository countryRepository) {
- this.countryRepository = countryRepository;
- }
- // }}
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/sample/fixtures/JoeBloggsFixture.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/sample/fixtures/JoeBloggsFixture.java b/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/sample/fixtures/JoeBloggsFixture.java
deleted file mode 100644
index 911830a..0000000
--- a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/sample/fixtures/JoeBloggsFixture.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.junit.sample.fixtures;
-
-import org.apache.isis.applib.fixtures.LogonFixture;
-
-public class JoeBloggsFixture extends LogonFixture {
-
- public JoeBloggsFixture() {
- super("jbloggs");
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/sample/fixtures/ProductsFixture.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/sample/fixtures/ProductsFixture.java b/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/sample/fixtures/ProductsFixture.java
deleted file mode 100644
index d82970b..0000000
--- a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/sample/fixtures/ProductsFixture.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.junit.sample.fixtures;
-
-import org.apache.log4j.Logger;
-
-import org.apache.isis.applib.fixtures.AbstractFixture;
-import org.apache.isis.viewer.junit.sample.service.ProductRepository;
-
-public class ProductsFixture extends AbstractFixture {
-
- // use ctrl+space to bring up the NO templates.
-
- // also, use CoffeeBytes code folding with
- // user-defined regions of {{ and }}
-
- // {{ Logger
- private final static Logger LOGGER = Logger.getLogger(ProductsFixture.class);
-
- public Logger getLOGGER() {
- return LOGGER;
- }
-
- // }}
-
- @Override
- public void install() {
- getLOGGER().debug("installing");
- getProductRepository().newProduct("355-40311", "Weekend camping pack", 5000);
- getProductRepository().newProduct("850-18003", "Stripy Wasp Catcher", 695);
- getProductRepository().newProduct("845-06203", "Combi Backpack Hamper", 5900);
- getProductRepository().newProduct("820-72721", "Folding Table", 4000);
- getProductRepository().newProduct("820-72725", "Folding Chair", 2500);
- getProductRepository().newProduct("845-01020", "Isotherm Cool Box", 2500);
- }
-
- // {{ Injected: ProductRepository
- private ProductRepository productRepository;
-
- /**
- * This field is not persisted, nor displayed to the user.
- */
- protected ProductRepository getProductRepository() {
- return this.productRepository;
- }
-
- /**
- * Injected by the application container.
- */
- public void setProductRepository(final ProductRepository productRepository) {
- this.productRepository = productRepository;
- }
- // }}
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/sample/service/CountryRepository.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/sample/service/CountryRepository.java b/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/sample/service/CountryRepository.java
deleted file mode 100644
index 2d2366d..0000000
--- a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/sample/service/CountryRepository.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.junit.sample.service;
-
-import java.util.List;
-
-import org.apache.log4j.Logger;
-
-import org.apache.isis.applib.AbstractFactoryAndRepository;
-import org.apache.isis.applib.annotation.Hidden;
-import org.apache.isis.applib.annotation.Named;
-import org.apache.isis.applib.filter.Filter;
-import org.apache.isis.viewer.junit.sample.domain.Country;
-
-@Named("Countries")
-public class CountryRepository extends AbstractFactoryAndRepository {
-
- // {{ Logger
- @SuppressWarnings("unused")
- private final static Logger LOGGER = Logger.getLogger(CountryRepository.class);
-
- // }}
-
- /**
- * Lists all countries in the repository.
- */
- public List<Country> showAll() {
- return allInstances(Country.class);
- }
-
- // {{ findByCode
- /**
- * Returns the Country with given code
- */
- public Country findByCode(@Named("Code") final String code) {
- return firstMatch(Country.class, new Filter<Country>() {
- @Override
- public boolean accept(final Country country) {
- return code.equals(country.getCode());
- }
- });
- }
-
- // }}
-
- /**
- * Creates a new countryGBR.
- *
- * <p>
- * For use by fixtures only.
- *
- * @return
- */
- @Hidden
- public Country newCountry(final String code, final String name) {
- final Country country = newTransientInstance(Country.class);
- country.setCode(code);
- country.setName(name);
- persist(country);
- return country;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/sample/service/CustomerRepository.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/sample/service/CustomerRepository.java b/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/sample/service/CustomerRepository.java
deleted file mode 100644
index bcf3a95..0000000
--- a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/sample/service/CustomerRepository.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.junit.sample.service;
-
-import java.util.List;
-
-import org.apache.log4j.Logger;
-
-import org.apache.isis.applib.AbstractFactoryAndRepository;
-import org.apache.isis.applib.annotation.Hidden;
-import org.apache.isis.applib.annotation.Named;
-import org.apache.isis.applib.filter.Filter;
-import org.apache.isis.viewer.junit.sample.domain.Country;
-import org.apache.isis.viewer.junit.sample.domain.Customer;
-
-@Named("Customers")
-public class CustomerRepository extends AbstractFactoryAndRepository {
-
- // use ctrl+space to bring up the NO templates.
-
- // also, use CoffeeBytes code folding with
- // user-defined regions of {{ and }}
-
- // {{ Logger
- @SuppressWarnings("unused")
- private final static Logger LOGGER = Logger.getLogger(CustomerRepository.class);
-
- // }}
-
- /**
- * Lists all customers in the repository.
- */
- public List<Customer> showAll() {
- return allInstances(Customer.class);
- }
-
- // {{ findAllByName, findByName
- /**
- * Returns a list of Customers with given last name.
- */
- public List<Customer> findAllByName(@Named("Last name") final String lastName) {
- return allMatches(Customer.class, new FilterLastName(lastName));
- }
-
- /**
- * Returns the first Customer with given last name.
- */
- public Customer findByName(@Named("Last name") final String lastName) {
- final Customer firstMatch = firstMatch(Customer.class, new FilterLastName(lastName));
- return firstMatch;
- }
-
- private final class FilterLastName implements Filter<Customer> {
- private final String name;
-
- private FilterLastName(final String name) {
- this.name = name;
- }
-
- @Override
- public boolean accept(final Customer customer) {
- return customer.getLastName().toLowerCase().contains(name.toLowerCase());
- }
- }
-
- // }}
-
- /**
- * Creates a new (still-transient) customer.
- *
- * @return
- */
- public Customer newCustomer() {
- final Customer customer = newTransientInstance(Customer.class);
- return customer;
- }
-
- /**
- * Creates a new (already persisted) customer.
- *
- * <p>
- * For use by fixtures only.
- *
- * @return
- */
- @Hidden
- public Customer newCustomer(final String firstName, final String lastName, final int customerNumber, final Country countryOfBirth) {
-
- final Customer customer = newCustomer();
- customer.setFirstName(firstName);
- customer.setLastName(lastName);
- customer.setCustomerNumber(customerNumber);
- customer.modifyCountryOfBirth(countryOfBirth);
-
- persist(customer);
- return customer;
- }
-
-}