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:36 UTC
[1/5] ISIS-409: junit viewer moved up to core...
Updated Branches:
refs/heads/master 55f931ae1 -> da47b564a
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/fixtures/ProductsFixture.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/fixtures/ProductsFixture.java b/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/fixtures/ProductsFixture.java
new file mode 100644
index 0000000..a7dfd7e
--- /dev/null
+++ b/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/fixtures/ProductsFixture.java
@@ -0,0 +1,72 @@
+/*
+ * 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.core.integtestsupport.legacy.sample.fixtures;
+
+import org.apache.log4j.Logger;
+
+import org.apache.isis.applib.fixtures.AbstractFixture;
+import org.apache.isis.core.integtestsupport.legacy.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/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/service/CountryRepository.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/service/CountryRepository.java b/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/service/CountryRepository.java
new file mode 100644
index 0000000..a1e2cea
--- /dev/null
+++ b/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/service/CountryRepository.java
@@ -0,0 +1,80 @@
+/*
+ * 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.core.integtestsupport.legacy.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.core.integtestsupport.legacy.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/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/service/CustomerRepository.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/service/CustomerRepository.java b/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/service/CustomerRepository.java
new file mode 100644
index 0000000..45a9d99
--- /dev/null
+++ b/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/service/CustomerRepository.java
@@ -0,0 +1,116 @@
+/*
+ * 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.core.integtestsupport.legacy.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.core.integtestsupport.legacy.sample.domain.Country;
+import org.apache.isis.core.integtestsupport.legacy.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;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/service/OrderRepository.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/service/OrderRepository.java b/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/service/OrderRepository.java
new file mode 100644
index 0000000..228466a
--- /dev/null
+++ b/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/service/OrderRepository.java
@@ -0,0 +1,67 @@
+/*
+ * 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.core.integtestsupport.legacy.sample.service;
+
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+
+import org.apache.isis.applib.AbstractFactoryAndRepository;
+import org.apache.isis.applib.annotation.Named;
+import org.apache.isis.core.integtestsupport.legacy.sample.domain.Customer;
+import org.apache.isis.core.integtestsupport.legacy.sample.domain.Order;
+
+@Named("Orders")
+public class OrderRepository extends AbstractFactoryAndRepository {
+
+ // use ctrl+space to bring up the NO templates.
+
+ // also, use CoffeeBytes code folding with
+ // user-defined regions of {{ and }}
+
+ @SuppressWarnings("unused")
+ private final static Logger LOGGER = Logger.getLogger(OrderRepository.class);
+
+ // {{ findRecentOrders
+ public List<Order> findRecentOrders(final Customer customer, @Named("Number of Orders") final Integer numberOfOrders) {
+ final List<Order> orders = customer.getOrders();
+ Collections.sort(orders, new Comparator<Order>() {
+ @Override
+ public int compare(final Order o1, final Order o2) {
+ final long time1 = o1.getOrderDate().getTime();
+ final long time2 = o2.getOrderDate().getTime();
+ return (int) (time2 - time1);
+ }
+ });
+ if (orders.size() < numberOfOrders) {
+ return orders;
+ } else {
+ return orders.subList(0, numberOfOrders);
+ }
+ }
+
+ public Integer default1FindRecentOrders() {
+ return 3;
+ }
+ // }}
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/service/ProductRepository.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/service/ProductRepository.java b/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/service/ProductRepository.java
new file mode 100644
index 0000000..d94aa6d
--- /dev/null
+++ b/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/service/ProductRepository.java
@@ -0,0 +1,103 @@
+/*
+ * 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.core.integtestsupport.legacy.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.core.integtestsupport.legacy.sample.domain.Customer;
+import org.apache.isis.core.integtestsupport.legacy.sample.domain.Product;
+
+@Named("Products")
+public class ProductRepository 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(ProductRepository.class);
+
+ // }}
+
+ /**
+ * Lists all products in the repository.
+ */
+ public List<Product> showAll() {
+ return allInstances(Product.class);
+ }
+
+ // {{ findByCode
+ /**
+ * Returns the Product with given code
+ */
+ public Product findByCode(@Named("Code") final String code) {
+ return firstMatch(Product.class, new Filter<Product>() {
+ @Override
+ public boolean accept(final Product product) {
+ return code.equals(product.getCode());
+ }
+ });
+ }
+
+ // }}
+
+ /**
+ * Creates a new product.
+ *
+ * <p>
+ * For use by fixtures only.
+ *
+ * @return
+ */
+ @Hidden
+ public Product newProduct(final String code, final String description, final int priceInPence) {
+ final Product product = newTransientInstance(Product.class);
+ product.setCode(code);
+ product.setDescription(description);
+ product.setPrice(new Double(priceInPence / 100));
+ persist(product);
+ return product;
+ }
+
+ /**
+ * Creates a new still transient product.
+ *
+ * <p>
+ * For use by tests only. Using this rather than {@link Customer} since
+ * {@link Product} has a {@link Product#validate()} method.
+ *
+ * @return
+ */
+ @Hidden
+ public Product newProduct() {
+ return newTransientInstance(Product.class);
+ }
+
+
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/core/pom.xml
----------------------------------------------------------------------
diff --git a/core/pom.xml b/core/pom.xml
index 78e674c..b485938 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -1346,7 +1346,7 @@ ${license.additional-notes}
</exclusions>
</dependency>
- <!-- Testing libraries (not scope=test because used by isis-viewer-junit) -->
+ <!-- Testing libraries (not scope=test because used by isis-core-integtest) -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/example/application/claims/pom.xml
----------------------------------------------------------------------
diff --git a/example/application/claims/pom.xml b/example/application/claims/pom.xml
index 60110fb..6babb5e 100644
--- a/example/application/claims/pom.xml
+++ b/example/application/claims/pom.xml
@@ -32,7 +32,6 @@
<isis-security-file.version>1.0.1-SNAPSHOT</isis-security-file.version>
<isis-viewer-dnd.version>1.0.0-SNAPSHOT</isis-viewer-dnd.version>
<isis-viewer-wicket.version>1.2.0-SNAPSHOT</isis-viewer-wicket.version>
- <isis-viewer-junit.version>1.0.0-SNAPSHOT</isis-viewer-junit.version>
<isis-viewer-scimpi.version>1.0.0-SNAPSHOT</isis-viewer-scimpi.version>
</properties>
@@ -189,14 +188,6 @@
<dependency>
<groupId>org.apache.isis.viewer</groupId>
- <artifactId>isis-viewer-junit</artifactId>
- <version>${isis-viewer-junit.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.isis.viewer</groupId>
<artifactId>isis-viewer-scimpi</artifactId>
<version>${isis-viewer-scimpi.version}</version>
<type>pom</type>
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/example/application/claims/viewer-dnd/pom.xml
----------------------------------------------------------------------
diff --git a/example/application/claims/viewer-dnd/pom.xml b/example/application/claims/viewer-dnd/pom.xml
index bd80a69..033bcd4 100644
--- a/example/application/claims/viewer-dnd/pom.xml
+++ b/example/application/claims/viewer-dnd/pom.xml
@@ -76,7 +76,6 @@
<artifactId>isis-core-metamodel</artifactId>
</dependency>
- <!-- isis default runtime -->
<dependency>
<groupId>org.apache.isis.core</groupId>
<artifactId>isis-core-webserver</artifactId>
@@ -104,6 +103,17 @@
<dependency>
<groupId>org.apache.isis.core</groupId>
+ <artifactId>isis-core-wrapper</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.isis.core</groupId>
+ <artifactId>isis-core-integtestsupport</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.isis.core</groupId>
<artifactId>isis-core-security</artifactId>
</dependency>
@@ -113,12 +123,6 @@
<artifactId>isis-viewer-dnd-impl</artifactId>
</dependency>
- <!-- JUnit Viewer dependencies -->
- <dependency>
- <groupId>org.apache.isis.viewer</groupId>
- <artifactId>isis-viewer-junit-impl</artifactId>
- <scope>test</scope>
- </dependency>
</dependencies>
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/example/application/claims/viewer-dnd/src/test/java/org/apache/isis/example/claims/junit/AbstractTest.java
----------------------------------------------------------------------
diff --git a/example/application/claims/viewer-dnd/src/test/java/org/apache/isis/example/claims/junit/AbstractTest.java b/example/application/claims/viewer-dnd/src/test/java/org/apache/isis/example/claims/junit/AbstractTest.java
index a1c6d38..a22752d 100644
--- a/example/application/claims/viewer-dnd/src/test/java/org/apache/isis/example/claims/junit/AbstractTest.java
+++ b/example/application/claims/viewer-dnd/src/test/java/org/apache/isis/example/claims/junit/AbstractTest.java
@@ -26,13 +26,13 @@ import org.junit.runner.RunWith;
import org.apache.isis.applib.DomainObjectContainer;
import org.apache.isis.applib.services.wrapper.WrapperFactory;
import org.apache.isis.applib.services.wrapper.WrapperObject;
+import org.apache.isis.core.integtestsupport.legacy.IsisTestRunner;
+import org.apache.isis.core.integtestsupport.legacy.Service;
+import org.apache.isis.core.integtestsupport.legacy.Services;
import org.apache.isis.core.wrapper.WrapperFactoryDefault;
import org.apache.isis.example.application.claims.dom.claim.ClaimRepository;
import org.apache.isis.example.application.claims.dom.employee.Employee;
import org.apache.isis.example.application.claims.dom.employee.EmployeeRepository;
-import org.apache.isis.viewer.junit.IsisTestRunner;
-import org.apache.isis.viewer.junit.Service;
-import org.apache.isis.viewer.junit.Services;
@RunWith(IsisTestRunner.class)
@Services({ @Service(ClaimRepository.class), @Service(EmployeeRepository.class), @Service(WrapperFactoryDefault.class) })
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/example/application/claims/viewer-dnd/src/test/java/org/apache/isis/example/claims/junit/ClaimSubmitTest.java
----------------------------------------------------------------------
diff --git a/example/application/claims/viewer-dnd/src/test/java/org/apache/isis/example/claims/junit/ClaimSubmitTest.java b/example/application/claims/viewer-dnd/src/test/java/org/apache/isis/example/claims/junit/ClaimSubmitTest.java
index d81b0d1..b72af1c 100644
--- a/example/application/claims/viewer-dnd/src/test/java/org/apache/isis/example/claims/junit/ClaimSubmitTest.java
+++ b/example/application/claims/viewer-dnd/src/test/java/org/apache/isis/example/claims/junit/ClaimSubmitTest.java
@@ -28,11 +28,11 @@ import java.util.List;
import org.junit.Test;
import org.apache.isis.applib.services.wrapper.DisabledException;
+import org.apache.isis.core.integtestsupport.legacy.Fixture;
+import org.apache.isis.core.integtestsupport.legacy.Fixtures;
import org.apache.isis.example.application.claims.dom.claim.Approver;
import org.apache.isis.example.application.claims.dom.claim.Claim;
import org.apache.isis.example.application.claims.fixture.ClaimsFixture;
-import org.apache.isis.viewer.junit.Fixture;
-import org.apache.isis.viewer.junit.Fixtures;
@Fixtures({ @Fixture(ClaimsFixture.class) })
public class ClaimSubmitTest extends AbstractTest {
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/example/application/claims/viewer-dnd/src/test/java/org/apache/isis/example/claims/junit/NewClaimTest.java
----------------------------------------------------------------------
diff --git a/example/application/claims/viewer-dnd/src/test/java/org/apache/isis/example/claims/junit/NewClaimTest.java b/example/application/claims/viewer-dnd/src/test/java/org/apache/isis/example/claims/junit/NewClaimTest.java
index 5dc9bf4..4e05c80 100644
--- a/example/application/claims/viewer-dnd/src/test/java/org/apache/isis/example/claims/junit/NewClaimTest.java
+++ b/example/application/claims/viewer-dnd/src/test/java/org/apache/isis/example/claims/junit/NewClaimTest.java
@@ -24,10 +24,10 @@ import static org.junit.Assert.assertThat;
import org.junit.Test;
+import org.apache.isis.core.integtestsupport.legacy.Fixture;
+import org.apache.isis.core.integtestsupport.legacy.Fixtures;
import org.apache.isis.example.application.claims.dom.claim.Claim;
import org.apache.isis.example.application.claims.fixture.ClaimsFixture;
-import org.apache.isis.viewer.junit.Fixture;
-import org.apache.isis.viewer.junit.Fixtures;
@Fixtures({ @Fixture(ClaimsFixture.class) })
public class NewClaimTest extends AbstractTest {
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/example/application/quickstart_dnd_junit_bdd/pom.xml
----------------------------------------------------------------------
diff --git a/example/application/quickstart_dnd_junit_bdd/pom.xml b/example/application/quickstart_dnd_junit_bdd/pom.xml
index 4596c2e..4907d38 100644
--- a/example/application/quickstart_dnd_junit_bdd/pom.xml
+++ b/example/application/quickstart_dnd_junit_bdd/pom.xml
@@ -39,7 +39,6 @@
<isis-profilestore-xml.version>1.0.0-SNAPSHOT</isis-profilestore-xml.version>
<isis-viewer-bdd.version>1.0.0-SNAPSHOT</isis-viewer-bdd.version>
<isis-viewer-dnd.version>1.0.0-SNAPSHOT</isis-viewer-dnd.version>
- <isis-viewer-junit.version>1.0.0-SNAPSHOT</isis-viewer-junit.version>
<isis-security-file.version>1.0.1-SNAPSHOT</isis-security-file.version>
</properties>
@@ -192,14 +191,6 @@
<dependency>
<groupId>org.apache.isis.viewer</groupId>
- <artifactId>isis-viewer-junit</artifactId>
- <version>${isis-viewer-junit.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.isis.viewer</groupId>
<artifactId>isis-viewer-bdd</artifactId>
<version>${isis-viewer-bdd.version}</version>
<type>pom</type>
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/example/application/quickstart_dnd_junit_bdd/tests-junit/pom.xml
----------------------------------------------------------------------
diff --git a/example/application/quickstart_dnd_junit_bdd/tests-junit/pom.xml b/example/application/quickstart_dnd_junit_bdd/tests-junit/pom.xml
index ca022bc..90c220c 100644
--- a/example/application/quickstart_dnd_junit_bdd/tests-junit/pom.xml
+++ b/example/application/quickstart_dnd_junit_bdd/tests-junit/pom.xml
@@ -65,10 +65,15 @@
<artifactId>isis-security-file</artifactId>
</dependency>
- <!-- isis viewers -->
+ <!-- isis testing -->
<dependency>
- <groupId>org.apache.isis.viewer</groupId>
- <artifactId>isis-viewer-junit-impl</artifactId>
+ <groupId>org.apache.isis.core</groupId>
+ <artifactId>isis-core-wrapper</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.isis.core</groupId>
+ <artifactId>isis-core-integtestsupport</artifactId>
<scope>test</scope>
</dependency>
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/example/application/quickstart_dnd_junit_bdd/tests-junit/src/test/java/junit/AbstractTest.java
----------------------------------------------------------------------
diff --git a/example/application/quickstart_dnd_junit_bdd/tests-junit/src/test/java/junit/AbstractTest.java b/example/application/quickstart_dnd_junit_bdd/tests-junit/src/test/java/junit/AbstractTest.java
index e3ab772..2a29b1f 100644
--- a/example/application/quickstart_dnd_junit_bdd/tests-junit/src/test/java/junit/AbstractTest.java
+++ b/example/application/quickstart_dnd_junit_bdd/tests-junit/src/test/java/junit/AbstractTest.java
@@ -28,11 +28,11 @@ import org.junit.runner.RunWith;
import org.apache.isis.applib.DomainObjectContainer;
import org.apache.isis.applib.services.wrapper.WrapperFactory;
import org.apache.isis.applib.services.wrapper.WrapperObject;
+import org.apache.isis.core.integtestsupport.legacy.ConfigDir;
+import org.apache.isis.core.integtestsupport.legacy.IsisTestRunner;
+import org.apache.isis.core.integtestsupport.legacy.Service;
+import org.apache.isis.core.integtestsupport.legacy.Services;
import org.apache.isis.core.wrapper.WrapperFactoryDefault;
-import org.apache.isis.viewer.junit.ConfigDir;
-import org.apache.isis.viewer.junit.IsisTestRunner;
-import org.apache.isis.viewer.junit.Service;
-import org.apache.isis.viewer.junit.Services;
@RunWith(IsisTestRunner.class)
@ConfigDir("../viewer-dnd/config") // acts as default, but can be overridden by annotations
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/example/application/quickstart_dnd_junit_bdd/tests-junit/src/test/java/junit/todo/ToDoItemRepositoryTest.java
----------------------------------------------------------------------
diff --git a/example/application/quickstart_dnd_junit_bdd/tests-junit/src/test/java/junit/todo/ToDoItemRepositoryTest.java b/example/application/quickstart_dnd_junit_bdd/tests-junit/src/test/java/junit/todo/ToDoItemRepositoryTest.java
index c163622..a0b25fd 100644
--- a/example/application/quickstart_dnd_junit_bdd/tests-junit/src/test/java/junit/todo/ToDoItemRepositoryTest.java
+++ b/example/application/quickstart_dnd_junit_bdd/tests-junit/src/test/java/junit/todo/ToDoItemRepositoryTest.java
@@ -34,8 +34,8 @@ import fixture.todo.ToDoItemsFixture;
import org.junit.Test;
-import org.apache.isis.viewer.junit.Fixture;
-import org.apache.isis.viewer.junit.Fixtures;
+import org.apache.isis.core.integtestsupport.legacy.Fixture;
+import org.apache.isis.core.integtestsupport.legacy.Fixtures;
@Fixtures({ @Fixture(ToDoItemsFixture.class), @Fixture(LogonAsSvenFixture.class) })
public class ToDoItemRepositoryTest extends AbstractTest {
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/example/application/quickstart_dnd_junit_bdd/tests-junit/src/test/java/junit/todo/ToDoItemTest.java
----------------------------------------------------------------------
diff --git a/example/application/quickstart_dnd_junit_bdd/tests-junit/src/test/java/junit/todo/ToDoItemTest.java b/example/application/quickstart_dnd_junit_bdd/tests-junit/src/test/java/junit/todo/ToDoItemTest.java
index f299b32..72ad8d3 100644
--- a/example/application/quickstart_dnd_junit_bdd/tests-junit/src/test/java/junit/todo/ToDoItemTest.java
+++ b/example/application/quickstart_dnd_junit_bdd/tests-junit/src/test/java/junit/todo/ToDoItemTest.java
@@ -31,8 +31,8 @@ import org.junit.Before;
import org.junit.Test;
import org.apache.isis.applib.services.wrapper.DisabledException;
-import org.apache.isis.viewer.junit.Fixture;
-import org.apache.isis.viewer.junit.Fixtures;
+import org.apache.isis.core.integtestsupport.legacy.Fixture;
+import org.apache.isis.core.integtestsupport.legacy.Fixtures;
@Fixtures({ @Fixture(ToDoItemsFixture.class), @Fixture(LogonAsSvenFixture.class) })
public class ToDoItemTest extends AbstractTest {
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index f2f0b21..48cfce0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -65,7 +65,6 @@
<module>component/viewer/wicket</module>
<module>component/viewer/restfulobjects</module>
<module>component/viewer/bdd</module>
- <module>component/viewer/junit</module>
<module>example/application/claims</module>
<module>example/application/quickstart_scimpi_nosql</module>
[3/5] ISIS-409: junit viewer moved up to core...
Posted by da...@apache.org.
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/OrderRepository.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/sample/service/OrderRepository.java b/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/sample/service/OrderRepository.java
deleted file mode 100644
index 3249123..0000000
--- a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/sample/service/OrderRepository.java
+++ /dev/null
@@ -1,67 +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.Collections;
-import java.util.Comparator;
-import java.util.List;
-
-import org.apache.log4j.Logger;
-
-import org.apache.isis.applib.AbstractFactoryAndRepository;
-import org.apache.isis.applib.annotation.Named;
-import org.apache.isis.viewer.junit.sample.domain.Customer;
-import org.apache.isis.viewer.junit.sample.domain.Order;
-
-@Named("Orders")
-public class OrderRepository extends AbstractFactoryAndRepository {
-
- // use ctrl+space to bring up the NO templates.
-
- // also, use CoffeeBytes code folding with
- // user-defined regions of {{ and }}
-
- @SuppressWarnings("unused")
- private final static Logger LOGGER = Logger.getLogger(OrderRepository.class);
-
- // {{ findRecentOrders
- public List<Order> findRecentOrders(final Customer customer, @Named("Number of Orders") final Integer numberOfOrders) {
- final List<Order> orders = customer.getOrders();
- Collections.sort(orders, new Comparator<Order>() {
- @Override
- public int compare(final Order o1, final Order o2) {
- final long time1 = o1.getOrderDate().getTime();
- final long time2 = o2.getOrderDate().getTime();
- return (int) (time2 - time1);
- }
- });
- if (orders.size() < numberOfOrders) {
- return orders;
- } else {
- return orders.subList(0, numberOfOrders);
- }
- }
-
- public Integer default1FindRecentOrders() {
- return 3;
- }
- // }}
-
-}
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/ProductRepository.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/sample/service/ProductRepository.java b/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/sample/service/ProductRepository.java
deleted file mode 100644
index e62be41..0000000
--- a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/sample/service/ProductRepository.java
+++ /dev/null
@@ -1,103 +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.Customer;
-import org.apache.isis.viewer.junit.sample.domain.Product;
-
-@Named("Products")
-public class ProductRepository 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(ProductRepository.class);
-
- // }}
-
- /**
- * Lists all products in the repository.
- */
- public List<Product> showAll() {
- return allInstances(Product.class);
- }
-
- // {{ findByCode
- /**
- * Returns the Product with given code
- */
- public Product findByCode(@Named("Code") final String code) {
- return firstMatch(Product.class, new Filter<Product>() {
- @Override
- public boolean accept(final Product product) {
- return code.equals(product.getCode());
- }
- });
- }
-
- // }}
-
- /**
- * Creates a new product.
- *
- * <p>
- * For use by fixtures only.
- *
- * @return
- */
- @Hidden
- public Product newProduct(final String code, final String description, final int priceInPence) {
- final Product product = newTransientInstance(Product.class);
- product.setCode(code);
- product.setDescription(description);
- product.setPrice(new Double(priceInPence / 100));
- persist(product);
- return product;
- }
-
- /**
- * Creates a new still transient product.
- *
- * <p>
- * For use by tests only. Using this rather than {@link Customer} since
- * {@link Product} has a {@link Product#validate()} method.
- *
- * @return
- */
- @Hidden
- public Product newProduct() {
- return newTransientInstance(Product.class);
- }
-
-
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/component/viewer/junit/tck/pom.xml
----------------------------------------------------------------------
diff --git a/component/viewer/junit/tck/pom.xml b/component/viewer/junit/tck/pom.xml
index b2dca09..0d82077 100644
--- a/component/viewer/junit/tck/pom.xml
+++ b/component/viewer/junit/tck/pom.xml
@@ -74,11 +74,15 @@
<artifactId>isis-core-security</artifactId>
</dependency>
- <!-- isis viewers -->
+ <!-- isis testing -->
<dependency>
- <groupId>org.apache.isis.viewer</groupId>
- <artifactId>isis-viewer-junit-impl</artifactId>
- <version>${isis-viewer-junit.version}</version>
+ <groupId>org.apache.isis.core</groupId>
+ <artifactId>isis-core-wrapper</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.isis.core</groupId>
+ <artifactId>isis-core-integtestsupport</artifactId>
<scope>test</scope>
</dependency>
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/component/viewer/junit/tck/src/test/java/junit/AbstractTest.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/tck/src/test/java/junit/AbstractTest.java b/component/viewer/junit/tck/src/test/java/junit/AbstractTest.java
index bf15176..5697fd2 100644
--- a/component/viewer/junit/tck/src/test/java/junit/AbstractTest.java
+++ b/component/viewer/junit/tck/src/test/java/junit/AbstractTest.java
@@ -26,12 +26,12 @@ import org.junit.runner.RunWith;
import org.apache.isis.applib.DomainObjectContainer;
import org.apache.isis.applib.services.wrapper.WrapperFactory;
import org.apache.isis.applib.services.wrapper.WrapperObject;
+import org.apache.isis.core.integtestsupport.legacy.ConfigDir;
+import org.apache.isis.core.integtestsupport.legacy.IsisTestRunner;
+import org.apache.isis.core.integtestsupport.legacy.Service;
+import org.apache.isis.core.integtestsupport.legacy.Services;
import org.apache.isis.core.tck.dom.scalars.PrimitiveValuedEntityRepository;
import org.apache.isis.core.wrapper.WrapperFactoryDefault;
-import org.apache.isis.viewer.junit.ConfigDir;
-import org.apache.isis.viewer.junit.IsisTestRunner;
-import org.apache.isis.viewer.junit.Service;
-import org.apache.isis.viewer.junit.Services;
@RunWith(IsisTestRunner.class)
@ConfigDir("../../viewer/dnd-tck/src/main/resources")
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/component/viewer/junit/tck/src/test/java/junit/todo/ScalarEntityRepositoryTest.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/tck/src/test/java/junit/todo/ScalarEntityRepositoryTest.java b/component/viewer/junit/tck/src/test/java/junit/todo/ScalarEntityRepositoryTest.java
index 444c229..7d71f96 100644
--- a/component/viewer/junit/tck/src/test/java/junit/todo/ScalarEntityRepositoryTest.java
+++ b/component/viewer/junit/tck/src/test/java/junit/todo/ScalarEntityRepositoryTest.java
@@ -31,10 +31,10 @@ import junit.AbstractTest;
import org.junit.Ignore;
import org.junit.Test;
+import org.apache.isis.core.integtestsupport.legacy.Fixture;
+import org.apache.isis.core.integtestsupport.legacy.Fixtures;
import org.apache.isis.core.tck.dom.scalars.PrimitiveValuedEntity;
import org.apache.isis.core.tck.fixture.scalars.PrimitiveValuedEntityFixture;
-import org.apache.isis.viewer.junit.Fixture;
-import org.apache.isis.viewer.junit.Fixtures;
@Fixtures({ @Fixture(PrimitiveValuedEntityFixture.class) })
public class ScalarEntityRepositoryTest extends AbstractTest {
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/component/viewer/junit/tck/src/test/java/junit/todo/ScalarEntityTest.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/tck/src/test/java/junit/todo/ScalarEntityTest.java b/component/viewer/junit/tck/src/test/java/junit/todo/ScalarEntityTest.java
index 889c101..57e1cea 100644
--- a/component/viewer/junit/tck/src/test/java/junit/todo/ScalarEntityTest.java
+++ b/component/viewer/junit/tck/src/test/java/junit/todo/ScalarEntityTest.java
@@ -24,10 +24,10 @@ import junit.AbstractTest;
import org.junit.Before;
import org.junit.Test;
+import org.apache.isis.core.integtestsupport.legacy.Fixture;
+import org.apache.isis.core.integtestsupport.legacy.Fixtures;
import org.apache.isis.core.tck.dom.scalars.PrimitiveValuedEntity;
import org.apache.isis.core.tck.fixture.scalars.PrimitiveValuedEntityFixture;
-import org.apache.isis.viewer.junit.Fixture;
-import org.apache.isis.viewer.junit.Fixtures;
@Fixtures({ @Fixture(PrimitiveValuedEntityFixture.class) })
public class ScalarEntityTest extends AbstractTest {
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/core/integtestsupport/pom.xml
----------------------------------------------------------------------
diff --git a/core/integtestsupport/pom.xml b/core/integtestsupport/pom.xml
index f13d81c..967969c 100644
--- a/core/integtestsupport/pom.xml
+++ b/core/integtestsupport/pom.xml
@@ -119,6 +119,13 @@
<artifactId>isis-core-runtime</artifactId>
</dependency>
+ <!-- isis testing -->
+ <dependency>
+ <groupId>org.apache.isis.core</groupId>
+ <artifactId>isis-core-wrapper</artifactId>
+ <scope>test</scope>
+ </dependency>
+
</dependencies>
</project>
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Authenticator.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Authenticator.java b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Authenticator.java
new file mode 100644
index 0000000..b788520
--- /dev/null
+++ b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Authenticator.java
@@ -0,0 +1,32 @@
+/*
+ * 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.core.integtestsupport.legacy;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target(ElementType.TYPE)
+@Inherited
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Authenticator {
+ Class<?> value();
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Authorizor.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Authorizor.java b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Authorizor.java
new file mode 100644
index 0000000..be399b3
--- /dev/null
+++ b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Authorizor.java
@@ -0,0 +1,32 @@
+/*
+ * 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.core.integtestsupport.legacy;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target(ElementType.TYPE)
+@Inherited
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Authorizor {
+ Class<?> value();
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/ConfigDir.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/ConfigDir.java b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/ConfigDir.java
new file mode 100644
index 0000000..eac566c
--- /dev/null
+++ b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/ConfigDir.java
@@ -0,0 +1,36 @@
+/*
+ * 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.core.integtestsupport.legacy;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * The location of the <tt>config</tt> directory, relative to the base.
+ */
+@Target(ElementType.TYPE)
+@Inherited
+@Retention(RetentionPolicy.RUNTIME)
+public @interface ConfigDir {
+ String value();
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Fixture.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Fixture.java b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Fixture.java
new file mode 100644
index 0000000..bf8a9f8
--- /dev/null
+++ b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Fixture.java
@@ -0,0 +1,33 @@
+/*
+ * 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.core.integtestsupport.legacy;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target(ElementType.TYPE)
+@Inherited
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Fixture {
+ Class<?> value();
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Fixtures.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Fixtures.java b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Fixtures.java
new file mode 100644
index 0000000..f2e25ed
--- /dev/null
+++ b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Fixtures.java
@@ -0,0 +1,33 @@
+/*
+ * 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.core.integtestsupport.legacy;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target(ElementType.TYPE)
+@Inherited
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Fixtures {
+ Fixture[] value();
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/IsisTestRunner.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/IsisTestRunner.java b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/IsisTestRunner.java
new file mode 100644
index 0000000..9a12e09
--- /dev/null
+++ b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/IsisTestRunner.java
@@ -0,0 +1,221 @@
+/*
+ * 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.core.integtestsupport.legacy;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import org.jmock.Mockery;
+import org.junit.internal.runners.InitializationError;
+import org.junit.internal.runners.JUnit4ClassRunner;
+import org.junit.internal.runners.MethodRoadie;
+import org.junit.internal.runners.TestClass;
+import org.junit.internal.runners.TestMethod;
+import org.junit.runner.Description;
+import org.junit.runner.notification.Failure;
+import org.junit.runner.notification.RunNotifier;
+
+import org.apache.isis.applib.fixtures.LogonFixture;
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.core.commons.config.IsisConfigurationBuilder;
+import org.apache.isis.core.commons.config.IsisConfigurationBuilderDefault;
+import org.apache.isis.core.integtestsupport.legacy.components.IsisSystemUsingInstallersWithinJunit;
+import org.apache.isis.core.metamodel.services.ServicesInjectorSpi;
+import org.apache.isis.core.runtime.authentication.AuthenticationRequest;
+import org.apache.isis.core.runtime.authentication.exploration.AuthenticationRequestExploration;
+import org.apache.isis.core.runtime.fixtures.authentication.AuthenticationRequestLogonFixture;
+import org.apache.isis.core.runtime.installers.InstallerLookupDefault;
+import org.apache.isis.core.runtime.system.DeploymentType;
+import org.apache.isis.core.runtime.system.SystemConstants;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
+import org.apache.isis.core.runtime.system.transaction.IsisTransactionManager;
+
+/**
+ * Copied from JMock, and with the same support.
+ *
+ */
+public class IsisTestRunner extends JUnit4ClassRunner {
+
+ private final Field mockeryField;
+
+ /**
+ * Only used during object construction.
+ */
+ public IsisTestRunner(final Class<?> testClass) throws InitializationError {
+ super(testClass);
+
+ // JMock initialization, adapted to allow for no mockery field.
+ mockeryField = findFieldAndMakeAccessible(testClass, Mockery.class);
+ }
+
+ private static String getConfigDir(final Class<?> javaClass) {
+ final ConfigDir fixturesAnnotation = javaClass.getAnnotation(ConfigDir.class);
+ if (fixturesAnnotation != null) {
+ return fixturesAnnotation.value();
+ }
+ return null;
+ }
+
+ @Override
+ protected void invokeTestMethod(final Method method, final RunNotifier notifier) {
+
+ final TestClass testClass = getTestClass();
+ final String configDirIfAny = getConfigDir(testClass.getJavaClass());
+
+ final Description description = methodDescription(method);
+
+ final IsisConfigurationBuilder isisConfigurationBuilder = new IsisConfigurationBuilderDefault(configDirIfAny);
+ isisConfigurationBuilder.add(SystemConstants.NOSPLASH_KEY, "" + true); // switch
+ // off
+ // splash
+
+ final InstallerLookupDefault installerLookup = new InstallerLookupDefault();
+ isisConfigurationBuilder.injectInto(installerLookup);
+ installerLookup.init();
+
+ IsisSystemUsingInstallersWithinJunit system = null;
+ AuthenticationSession session = null;
+ try {
+ // init the system; cf similar code in Isis and
+ // IsisServletContextInitializer
+ final DeploymentType deploymentType = DeploymentType.PROTOTYPE;
+
+ // TODO: replace with regular IsisSystem and remove this subclass.
+ system = new IsisSystemUsingInstallersWithinJunit(deploymentType, installerLookup, testClass);
+
+ system.init();
+
+ // specific to this bootstrap mechanism
+ AuthenticationRequest request;
+ final LogonFixture logonFixture = system.getFixturesInstaller().getLogonFixture();
+ if (logonFixture != null) {
+ request = new AuthenticationRequestLogonFixture(logonFixture);
+ } else {
+ request = new AuthenticationRequestExploration(logonFixture);
+ }
+ session = IsisContext.getAuthenticationManager().authenticate(request);
+
+ IsisContext.openSession(session);
+ getTransactionManager().startTransaction();
+
+ final Object test = createTest();
+ getServicesInjector().injectServicesInto(test);
+
+ final TestMethod testMethod = wrapMethod(method);
+ new MethodRoadie(test, testMethod, notifier, description).run();
+
+ getTransactionManager().endTransaction();
+
+ } catch (final InvocationTargetException e) {
+ testAborted(notifier, description, e.getCause());
+ getTransactionManager().abortTransaction();
+ return;
+ } catch (final Exception e) {
+ testAborted(notifier, description, e);
+ return;
+ } finally {
+ if (system != null) {
+ if (session != null) {
+ IsisContext.closeSession();
+ }
+ system.shutdown();
+ }
+ }
+ }
+
+ private void testAborted(final RunNotifier notifier, final Description description, final Throwable e) {
+ notifier.fireTestStarted(description);
+ notifier.fireTestFailure(new Failure(description, e));
+ notifier.fireTestFinished(description);
+ }
+
+ /**
+ * Taken from JMock's runner.
+ */
+ @Override
+ protected TestMethod wrapMethod(final Method method) {
+ return new TestMethod(method, getTestClass()) {
+ @Override
+ public void invoke(final Object testFixture) throws IllegalAccessException, InvocationTargetException {
+
+ super.invoke(testFixture);
+
+ if (mockeryField != null) {
+ mockeryOf(testFixture).assertIsSatisfied();
+ }
+ }
+ };
+ }
+
+ /**
+ * JMock code.
+ *
+ * @param test
+ * @return
+ */
+ protected Mockery mockeryOf(final Object test) {
+ if (mockeryField == null) {
+ return null;
+ }
+ try {
+ final Mockery mockery = (Mockery) mockeryField.get(test);
+ if (mockery == null) {
+ throw new IllegalStateException(String.format("Mockery named '%s' is null", mockeryField.getName()));
+ }
+ return mockery;
+ } catch (final IllegalAccessException e) {
+ throw new IllegalStateException(String.format("cannot get value of field %s", mockeryField.getName()), e);
+ }
+ }
+
+ /**
+ * Adapted from JMock code.
+ */
+ static Field findFieldAndMakeAccessible(final Class<?> testClass, final Class<?> clazz) throws InitializationError {
+ for (Class<?> c = testClass; c != Object.class; c = c.getSuperclass()) {
+ for (final Field field : c.getDeclaredFields()) {
+ if (clazz.isAssignableFrom(field.getType())) {
+ field.setAccessible(true);
+ return field;
+ }
+ }
+ }
+ return null;
+ }
+
+ // /////////////////////////////////////////////////////
+ // Dependencies (from context)
+ // /////////////////////////////////////////////////////
+
+ private static PersistenceSession getPersistenceSession() {
+ return IsisContext.getPersistenceSession();
+ }
+
+ private static ServicesInjectorSpi getServicesInjector() {
+ return getPersistenceSession().getServicesInjector();
+ }
+
+ private static IsisTransactionManager getTransactionManager() {
+ return getPersistenceSession().getTransactionManager();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Persistor.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Persistor.java b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Persistor.java
new file mode 100644
index 0000000..32ad6e0
--- /dev/null
+++ b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Persistor.java
@@ -0,0 +1,32 @@
+/*
+ * 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.core.integtestsupport.legacy;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target(ElementType.TYPE)
+@Inherited
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Persistor {
+ Class<?> value();
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Service.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Service.java b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Service.java
new file mode 100644
index 0000000..4e52531
--- /dev/null
+++ b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Service.java
@@ -0,0 +1,33 @@
+/*
+ * 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.core.integtestsupport.legacy;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target(ElementType.TYPE)
+@Inherited
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Service {
+ Class<?> value();
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Services.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Services.java b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Services.java
new file mode 100644
index 0000000..f4290d5
--- /dev/null
+++ b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Services.java
@@ -0,0 +1,33 @@
+/*
+ * 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.core.integtestsupport.legacy;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target(ElementType.TYPE)
+@Inherited
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Services {
+ Service[] value();
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/components/AnnotationInstaller.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/components/AnnotationInstaller.java b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/components/AnnotationInstaller.java
new file mode 100644
index 0000000..9f743ac
--- /dev/null
+++ b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/components/AnnotationInstaller.java
@@ -0,0 +1,96 @@
+/*
+ * 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.core.integtestsupport.legacy.components;
+
+import org.apache.isis.core.integtestsupport.legacy.Authenticator;
+import org.apache.isis.core.integtestsupport.legacy.Authorizor;
+import org.apache.isis.core.integtestsupport.legacy.Persistor;
+import org.apache.isis.core.objectstore.InMemoryPersistenceMechanismInstaller;
+import org.apache.isis.core.runtime.authentication.AuthenticationManagerInstaller;
+import org.apache.isis.core.runtime.authorization.AuthorizationManagerInstaller;
+import org.apache.isis.core.runtime.installerregistry.installerapi.PersistenceMechanismInstaller;
+import org.apache.isis.core.security.authentication.BypassAuthenticationManagerInstaller;
+import org.apache.isis.core.security.authorization.BypassAuthorizationManagerInstaller;
+
+public class AnnotationInstaller {
+
+ /**
+ * Should be called prior to installing; typically called immediately after
+ * instantiation.
+ *
+ * <p>
+ * Note: an alternative design would be to have a 1-arg constructor, but the
+ * convention for installers is to make them no-arg.
+ */
+ // {{ AuthenticationManagerInstaller
+ public AuthenticationManagerInstaller addAuthenticatorAnnotatedOn(final Class<?> javaClass) throws InstantiationException, IllegalAccessException {
+ final Authenticator authenticatorAnnotation = javaClass.getAnnotation(Authenticator.class);
+ if (authenticatorAnnotation != null) {
+ return addAuthenticatorRepresentedBy(authenticatorAnnotation);
+ } else {
+ return new BypassAuthenticationManagerInstaller();
+ }
+
+ }
+
+ private AuthenticationManagerInstaller addAuthenticatorRepresentedBy(final Authenticator authenticatorAnnotation) throws InstantiationException, IllegalAccessException {
+ final Class<?> fixtureClass = authenticatorAnnotation.value();
+ return (AuthenticationManagerInstaller) fixtureClass.newInstance();
+ }
+
+ // }}
+
+ // {{ AuthorizationManagerInstaller
+ public AuthorizationManagerInstaller addAuthorizerAnnotatedOn(final Class<?> javaClass) throws InstantiationException, IllegalAccessException {
+ final Authorizor authorizorAnnotation = javaClass.getAnnotation(Authorizor.class);
+ if (authorizorAnnotation != null) {
+ return addAuthorizerRepresentedBy(authorizorAnnotation);
+ } else {
+ return new BypassAuthorizationManagerInstaller();
+ }
+
+ }
+
+ private AuthorizationManagerInstaller addAuthorizerRepresentedBy(final Authorizor authorizorAnnotation) throws InstantiationException, IllegalAccessException {
+ final Class<?> fixtureClass = authorizorAnnotation.value();
+ return (AuthorizationManagerInstaller) fixtureClass.newInstance();
+ }
+
+ // }}
+
+ // {{ PersistenceMechanismInstaller
+ public PersistenceMechanismInstaller addPersistorAnnotatedOn(final Class<?> javaClass) throws InstantiationException, IllegalAccessException {
+ final Persistor annotation = javaClass.getAnnotation(Persistor.class);
+ if (annotation != null) {
+ return addPersistorRepresentedBy(annotation);
+ } else {
+ return new InMemoryPersistenceMechanismInstaller();
+ }
+
+ }
+
+ private PersistenceMechanismInstaller addPersistorRepresentedBy(final Persistor annotation) throws InstantiationException, IllegalAccessException {
+ final Class<?> fixtureClass = annotation.value();
+ return (PersistenceMechanismInstaller) fixtureClass.newInstance();
+ }
+ // }}
+
+ // new InMemoryUserProfileStoreInstaller();
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/components/FixtureInstallerAnnotatedClass.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/components/FixtureInstallerAnnotatedClass.java b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/components/FixtureInstallerAnnotatedClass.java
new file mode 100644
index 0000000..43b30ed
--- /dev/null
+++ b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/components/FixtureInstallerAnnotatedClass.java
@@ -0,0 +1,88 @@
+/*
+ * 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.core.integtestsupport.legacy.components;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.isis.core.integtestsupport.legacy.Fixture;
+import org.apache.isis.core.integtestsupport.legacy.Fixtures;
+import org.apache.isis.core.runtime.fixtures.FixturesInstallerAbstract;
+import org.apache.isis.core.runtime.fixtures.FixturesInstallerDelegate;
+
+public class FixtureInstallerAnnotatedClass extends FixturesInstallerAbstract {
+
+ private final List<Object> fixtures = new ArrayList<Object>();
+
+ /**
+ * @see #addFixturesAnnotatedOn(Class)
+ */
+ public FixtureInstallerAnnotatedClass() {
+ super("annotated");
+ }
+
+ // ///////////////////////////////////////////
+ // Hook method
+ // ///////////////////////////////////////////
+
+ /**
+ * Just copies the fixtures added using
+ * {@link #addFixturesAnnotatedOn(Class)} into the delegate.
+ */
+ @Override
+ protected void addFixturesTo(final FixturesInstallerDelegate delegate) {
+ for (final Object fixture : fixtures) {
+ delegate.addFixture(fixture);
+ }
+ }
+
+ // ///////////////////////////////////////////
+ // addFixturesAnnotatedOn (not API)
+ // ///////////////////////////////////////////
+
+ /**
+ * Should be called prior to installing; typically called immediately after
+ * instantiation.
+ *
+ * <p>
+ * Note: an alternative design would be to have a 1-arg constructor, but the
+ * convention for installers is to make them no-arg.
+ */
+ public void addFixturesAnnotatedOn(final Class<?> javaClass) throws InstantiationException, IllegalAccessException {
+ final Fixtures fixturesAnnotation = javaClass.getAnnotation(Fixtures.class);
+ if (fixturesAnnotation != null) {
+ final Fixture[] fixtureAnnotations = fixturesAnnotation.value();
+ for (final Fixture fixtureAnnotation : fixtureAnnotations) {
+ addFixtureRepresentedBy(fixtureAnnotation, fixtures);
+ }
+ }
+
+ final Fixture fixtureAnnotation = javaClass.getAnnotation(Fixture.class);
+ if (fixtureAnnotation != null) {
+ addFixtureRepresentedBy(fixtureAnnotation, fixtures);
+ }
+ }
+
+ private void addFixtureRepresentedBy(final Fixture fixtureAnnotation, final List<Object> fixtures) throws InstantiationException, IllegalAccessException {
+ final Class<?> fixtureClass = fixtureAnnotation.value();
+ fixtures.add(fixtureClass.newInstance());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/components/IsisSystemUsingInstallersWithinJunit.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/components/IsisSystemUsingInstallersWithinJunit.java b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/components/IsisSystemUsingInstallersWithinJunit.java
new file mode 100644
index 0000000..b223c22
--- /dev/null
+++ b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/components/IsisSystemUsingInstallersWithinJunit.java
@@ -0,0 +1,77 @@
+/*
+ * 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.core.integtestsupport.legacy.components;
+
+import org.junit.internal.runners.TestClass;
+
+import org.apache.isis.core.commons.exceptions.IsisException;
+import org.apache.isis.core.profilestore.InMemoryUserProfileStoreInstaller;
+import org.apache.isis.core.runtime.installerregistry.InstallerLookup;
+import org.apache.isis.core.runtime.system.DeploymentType;
+import org.apache.isis.core.runtime.systemusinginstallers.IsisSystemUsingInstallers;
+
+public class IsisSystemUsingInstallersWithinJunit extends IsisSystemUsingInstallers {
+
+ private final TestClass testClass;
+
+ public IsisSystemUsingInstallersWithinJunit(final DeploymentType deploymentType, final InstallerLookup installerLookup, final TestClass testClass) {
+ super(deploymentType, installerLookup);
+ installerLookup.getConfigurationBuilder().add("isis.deploymentType", deploymentType.nameLowerCase());
+
+ this.testClass = testClass;
+
+ final AnnotationInstaller installer = new AnnotationInstaller();
+
+ try {
+ setAuthenticationInstaller(getInstallerLookup().injectDependenciesInto(installer.addAuthenticatorAnnotatedOn(this.testClass.getJavaClass())));
+
+ setAuthorizationInstaller(getInstallerLookup().injectDependenciesInto(installer.addAuthorizerAnnotatedOn(this.testClass.getJavaClass())));
+
+ setPersistenceMechanismInstaller(getInstallerLookup().injectDependenciesInto(installer.addPersistorAnnotatedOn(this.testClass.getJavaClass())));
+
+ setUserProfileStoreInstaller(getInstallerLookup().injectDependenciesInto(new InMemoryUserProfileStoreInstaller()));
+
+ // fixture installer
+ final FixtureInstallerAnnotatedClass fixtureInstaller = new FixtureInstallerAnnotatedClass();
+ fixtureInstaller.addFixturesAnnotatedOn(this.testClass.getJavaClass());
+ setFixtureInstaller(fixtureInstaller);
+ } catch (final InstantiationException e) {
+ throw new IsisException(e);
+ } catch (final IllegalAccessException e) {
+ throw new IsisException(e);
+ }
+
+ // services installer
+ final ServicesInstallerAnnotatedClass servicesInstaller = new ServicesInstallerAnnotatedClass();
+ try {
+ servicesInstaller.addServicesAnnotatedOn(this.testClass.getJavaClass());
+ } catch (final InstantiationException e) {
+ throw new IsisException(e);
+ } catch (final IllegalAccessException e) {
+ throw new IsisException(e);
+ }
+ setServicesInstaller(servicesInstaller);
+ }
+
+ public TestClass getTestClass() {
+ return testClass;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/components/ServicesInstallerAnnotatedClass.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/components/ServicesInstallerAnnotatedClass.java b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/components/ServicesInstallerAnnotatedClass.java
new file mode 100644
index 0000000..3aae9e5
--- /dev/null
+++ b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/components/ServicesInstallerAnnotatedClass.java
@@ -0,0 +1,68 @@
+/*
+ * 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.core.integtestsupport.legacy.components;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.isis.core.integtestsupport.legacy.Service;
+import org.apache.isis.core.integtestsupport.legacy.Services;
+import org.apache.isis.core.runtime.services.ServicesInstallerAbstract;
+
+public class ServicesInstallerAnnotatedClass extends ServicesInstallerAbstract {
+
+ public ServicesInstallerAnnotatedClass() {
+ super("annotated");
+ }
+
+ public void addServicesAnnotatedOn(final Class<?> javaClass) throws InstantiationException, IllegalAccessException {
+ final List<Object> services = new ArrayList<Object>();
+ addServicesAnnotatedOn(javaClass, services);
+ addServices(services);
+ }
+
+ private void addServicesAnnotatedOn(final Class<?> testClass, final List<Object> services) throws InstantiationException, IllegalAccessException {
+ final Services servicesAnnotation = testClass.getAnnotation(Services.class);
+ if (servicesAnnotation != null) {
+ final Service[] serviceAnnotations = servicesAnnotation.value();
+ for (final Service serviceAnnotation : serviceAnnotations) {
+ addServiceRepresentedBy(serviceAnnotation, services);
+ }
+ }
+
+ final Service serviceAnnotation = testClass.getAnnotation(Service.class);
+ if (serviceAnnotation != null) {
+ addServiceRepresentedBy(serviceAnnotation, services);
+ }
+ }
+
+ private void addServiceRepresentedBy(final Service serviceAnnotation, final List<Object> services) throws InstantiationException, IllegalAccessException {
+ final Class<?> serviceClass = serviceAnnotation.value();
+ // there's no need to unravel any Collections of services,
+ // because the ServiceLoader will do it for us later.
+ services.add(serviceClass.newInstance());
+ }
+
+ @Override
+ public List<Class<?>> getTypes() {
+ return listOf(List.class); // ie List<Object.class>, of services
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/AbstractTest.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/AbstractTest.java b/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/AbstractTest.java
new file mode 100644
index 0000000..7f23be5
--- /dev/null
+++ b/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/AbstractTest.java
@@ -0,0 +1,132 @@
+/*
+ * 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.core.integtestsupport.legacy;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.runner.RunWith;
+
+import org.apache.isis.applib.DomainObjectContainer;
+import org.apache.isis.applib.services.wrapper.WrapperFactory;
+import org.apache.isis.core.integtestsupport.legacy.sample.domain.Country;
+import org.apache.isis.core.integtestsupport.legacy.sample.domain.Customer;
+import org.apache.isis.core.integtestsupport.legacy.sample.domain.Product;
+import org.apache.isis.core.integtestsupport.legacy.sample.fixtures.CountriesFixture;
+import org.apache.isis.core.integtestsupport.legacy.sample.fixtures.CustomerOrdersFixture;
+import org.apache.isis.core.integtestsupport.legacy.sample.fixtures.CustomersFixture;
+import org.apache.isis.core.integtestsupport.legacy.sample.fixtures.ProductsFixture;
+import org.apache.isis.core.integtestsupport.legacy.sample.service.CountryRepository;
+import org.apache.isis.core.integtestsupport.legacy.sample.service.CustomerRepository;
+import org.apache.isis.core.integtestsupport.legacy.sample.service.OrderRepository;
+import org.apache.isis.core.integtestsupport.legacy.sample.service.ProductRepository;
+import org.apache.isis.core.wrapper.WrapperFactoryDefault;
+
+@RunWith(IsisTestRunner.class)
+@Fixtures({ @Fixture(CountriesFixture.class), @Fixture(ProductsFixture.class), @Fixture(CustomersFixture.class), @Fixture(CustomerOrdersFixture.class) })
+@Services({ @Service(CountryRepository.class), @Service(ProductRepository.class), @Service(CustomerRepository.class), @Service(OrderRepository.class), @Service(WrapperFactoryDefault.class) })
+public abstract class AbstractTest {
+
+ protected Customer custJsDO;
+ protected Customer custJsWO;
+
+ protected Product product355DO;
+ protected Product product355VO;
+
+ protected Product product850DO;
+
+ protected Country countryGbrDO;
+ protected Country countryGbrVO;
+
+ protected Country countryUsaDO;
+ protected Country countryAusDO;
+
+ private ProductRepository productRepository;
+ private CustomerRepository customerRepository;
+ private CountryRepository countryRepository;
+
+ private DomainObjectContainer domainObjectContainer;
+ private WrapperFactory wrapperFactory;
+
+ @Before
+ public void setUp() {
+
+ product355DO = productRepository.findByCode("355-40311");
+ product355VO = wrapperFactory.wrap(product355DO);
+ product850DO = productRepository.findByCode("850-18003");
+
+ countryGbrDO = countryRepository.findByCode("GBR");
+ countryGbrVO = wrapperFactory.wrap(countryGbrDO);
+
+ countryUsaDO = countryRepository.findByCode("USA");
+ countryAusDO = countryRepository.findByCode("AUS");
+
+ custJsDO = customerRepository.findByName("Pawson");
+ custJsWO = wrapperFactory.wrap(custJsDO);
+ }
+
+ @After
+ public void tearDown() {
+ }
+
+ // //////////////////////////////////////////////////////
+ // Injected.
+ // //////////////////////////////////////////////////////
+
+ protected WrapperFactory getWrapperFactory() {
+ return wrapperFactory;
+ }
+
+ public void setWrapperFactory(final WrapperFactory headlessViewer) {
+ this.wrapperFactory = headlessViewer;
+ }
+
+ protected DomainObjectContainer getDomainObjectContainer() {
+ return domainObjectContainer;
+ }
+
+ public void setDomainObjectContainer(final DomainObjectContainer domainObjectContainer) {
+ this.domainObjectContainer = domainObjectContainer;
+ }
+
+ protected ProductRepository getProductRepository() {
+ return productRepository;
+ }
+
+ public void setProductRepository(final ProductRepository productRepository) {
+ this.productRepository = productRepository;
+ }
+
+ protected CustomerRepository getCustomerRepository() {
+ return customerRepository;
+ }
+
+ public void setCustomerRepository(final CustomerRepository customerRepository) {
+ this.customerRepository = customerRepository;
+ }
+
+ protected CountryRepository getCountryRepository() {
+ return countryRepository;
+ }
+
+ public void setCountryRepository(final CountryRepository countryRepository) {
+ this.countryRepository = countryRepository;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/DefaultAndChoicesTest.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/DefaultAndChoicesTest.java b/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/DefaultAndChoicesTest.java
new file mode 100644
index 0000000..edcc3a3
--- /dev/null
+++ b/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/DefaultAndChoicesTest.java
@@ -0,0 +1,42 @@
+/*
+ * 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.core.integtestsupport.legacy;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class DefaultAndChoicesTest extends AbstractTest {
+
+ @Test
+ public void defaults() {
+ final Object[] defaultPlaceOrder = custJsWO.defaultPlaceOrder();
+ assertThat(defaultPlaceOrder.length, is(2));
+ }
+
+ @Ignore("not yet tested")
+ @Test
+ public void choicesDefaults() {
+ // not tested.
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/InteractionListenerTest.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/InteractionListenerTest.java b/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/InteractionListenerTest.java
new file mode 100644
index 0000000..8669781
--- /dev/null
+++ b/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/InteractionListenerTest.java
@@ -0,0 +1,54 @@
+/*
+ * 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.core.integtestsupport.legacy;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.junit.Assert.assertThat;
+
+import org.junit.Test;
+
+import org.apache.isis.applib.events.InteractionEvent;
+import org.apache.isis.applib.events.PropertyAccessEvent;
+import org.apache.isis.applib.services.wrapper.listeners.InteractionAdapter;
+import org.apache.isis.applib.services.wrapper.listeners.InteractionListener;
+import org.apache.isis.core.integtestsupport.legacy.sample.domain.Customer;
+
+public class InteractionListenerTest extends AbstractTest {
+
+ @Test
+ public void shouldBeAbleToAddListener() {
+ final Customer proxiedCustRP = getWrapperFactory().wrap(custJsDO);
+ final InteractionEvent[] events = { null };
+ final InteractionListener l = new InteractionAdapter() {
+ @Override
+ public void propertyAccessed(final PropertyAccessEvent ev) {
+ events[0] = ev;
+ }
+ };
+ getWrapperFactory().addInteractionListener(l);
+
+ proxiedCustRP.getFirstName();
+ assertThat(events[0], notNullValue());
+ final PropertyAccessEvent ev = (PropertyAccessEvent) events[0];
+ assertThat(ev.getMemberNaturalName(), is("First Name"));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/MemberDisabledTest.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/MemberDisabledTest.java b/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/MemberDisabledTest.java
new file mode 100644
index 0000000..5ce3f2d
--- /dev/null
+++ b/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/MemberDisabledTest.java
@@ -0,0 +1,131 @@
+/*
+ * 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.core.integtestsupport.legacy;
+
+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 java.util.List;
+
+import org.junit.Test;
+
+import org.apache.isis.applib.services.wrapper.DisabledException;
+import org.apache.isis.core.integtestsupport.legacy.sample.domain.Order;
+import org.apache.isis.core.progmodel.facets.members.disabled.annotation.DisabledFacetAnnotation;
+import org.apache.isis.core.progmodel.facets.members.disabled.method.DisableForContextFacetViaMethod;
+
+public class MemberDisabledTest extends AbstractTest {
+
+ @Test
+ public void whenValueDisabledForValueThenThrowsException() {
+ custJsDO.disableFirstName = "cannot alter";
+ try {
+ custJsWO.setFirstName("Dick");
+ fail("Should have thrown exception");
+ } catch (final DisabledException ex) {
+ assertThat(ex.getAdvisorClass(), classEqualTo(DisableForContextFacetViaMethod.class));
+ assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("First Name"));
+ assertThat(ex.getMessage(), equalTo("cannot alter"));
+ }
+ }
+
+ @Test
+ public void whenValueDisabledForNullThenThrowsException() {
+ custJsDO.disableFirstName = "cannot alter";
+ try {
+ custJsWO.setFirstName(null);
+ fail("Should have thrown exception");
+ } catch (final DisabledException ex) {
+ assertThat(ex.getAdvisorClass(), classEqualTo(DisableForContextFacetViaMethod.class));
+ assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("First Name"));
+ assertThat(ex.getMessage(), equalTo("cannot alter"));
+ }
+ }
+
+ @Test
+ public void whenAssociationDisabledForReferenceThenThrowsException() {
+ custJsDO.disableCountryOfBirth = "cannot alter";
+ try {
+ custJsWO.setCountryOfBirth(countryUsaDO);
+ fail("Should have thrown exception");
+ } catch (final DisabledException ex) {
+ assertThat(ex.getAdvisorClass(), classEqualTo(DisableForContextFacetViaMethod.class));
+ assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Country Of Birth"));
+ assertThat(ex.getMessage(), equalTo("cannot alter"));
+ }
+ }
+
+ @Test
+ public void whenAssociationDisabledForNullThenThrowsException() {
+ custJsDO.disableCountryOfBirth = "cannot alter";
+ try {
+ custJsWO.setCountryOfBirth(null);
+ fail("Should have thrown exception");
+ } catch (final DisabledException ex) {
+ assertThat(ex.getAdvisorClass(), classEqualTo(DisableForContextFacetViaMethod.class));
+ assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Country Of Birth"));
+ assertThat(ex.getMessage(), equalTo("cannot alter"));
+ }
+ }
+
+ @Test
+ public void whenCollectionDisabledThenAddToThrowsException() {
+ final List<Order> orders = custJsWO.getOrders();
+ final Order order = orders.get(0);
+ try {
+ custJsWO.addToMoreOrders(order);
+ fail("Should have thrown exception");
+ } catch (final DisabledException ex) {
+ assertThat(ex.getAdvisorClass(), classEqualTo(DisabledFacetAnnotation.class));
+ assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("More Orders"));
+ assertThat(ex.getMessage(), equalTo("Always disabled"));
+ }
+ }
+
+ @Test
+ public void whenCollectionDisabledThenRemovefromThrowsException() {
+ custJsDO.addToVisitedCountries(countryUsaDO);
+ custJsDO.disableVisitedCountries = "cannot alter";
+ try {
+ custJsWO.removeFromVisitedCountries(countryUsaDO);
+ fail("Should have thrown exception");
+ } catch (final DisabledException ex) {
+ assertThat(ex.getAdvisorClass(), classEqualTo(DisableForContextFacetViaMethod.class));
+ assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Visited Countries"));
+ assertThat(ex.getMessage(), equalTo("cannot alter"));
+ }
+ }
+
+ @Test
+ public void whenActionDisabledThenThrowsException() {
+ custJsDO.disablePlaceOrder = "cannot invoke";
+ try {
+ custJsWO.placeOrder(product355DO, 3);
+ fail("Should have thrown exception");
+ } catch (final DisabledException ex) {
+ assertThat(ex.getAdvisorClass(), classEqualTo(DisableForContextFacetViaMethod.class));
+ assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Place Order"));
+ assertThat(ex.getMessage(), equalTo("cannot invoke"));
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/MemberHiddenTest.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/MemberHiddenTest.java b/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/MemberHiddenTest.java
new file mode 100644
index 0000000..b0589b2
--- /dev/null
+++ b/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/MemberHiddenTest.java
@@ -0,0 +1,357 @@
+/*
+ * 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.core.integtestsupport.legacy;
+
+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.HiddenException;
+import org.apache.isis.core.integtestsupport.legacy.sample.domain.Country;
+import org.apache.isis.core.progmodel.facets.members.hidden.annotation.HiddenFacetForMemberAnnotation;
+import org.apache.isis.core.progmodel.facets.members.hidden.forsession.HideForSessionFacetViaMethod;
+import org.apache.isis.core.progmodel.facets.members.hidden.method.HideForContextFacetViaMethod;
+
+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"));
+ }
+ }
+
+}
[2/5] ISIS-409: junit viewer moved up to core...
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/MemberInvalidTest.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/MemberInvalidTest.java b/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/MemberInvalidTest.java
new file mode 100644
index 0000000..8551a1f
--- /dev/null
+++ b/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/MemberInvalidTest.java
@@ -0,0 +1,189 @@
+/*
+ * 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.core.integtestsupport.legacy;
+
+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.InvalidException;
+import org.apache.isis.core.integtestsupport.legacy.sample.domain.Country;
+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;
+import org.apache.isis.core.progmodel.facets.collections.validate.CollectionValidateRemoveFromFacetViaMethod;
+import org.apache.isis.core.progmodel.facets.properties.validate.PropertyValidateFacetViaMethod;
+import org.apache.isis.core.progmodel.facets.properties.validate.maxlenannot.MaxLengthFacetAnnotationForProperty;
+import org.apache.isis.core.progmodel.facets.properties.validate.regexannot.RegExFacetAnnotationForProperty;
+
+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");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/MemberModifyTest.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/MemberModifyTest.java b/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/MemberModifyTest.java
new file mode 100644
index 0000000..96fd0ff
--- /dev/null
+++ b/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/MemberModifyTest.java
@@ -0,0 +1,223 @@
+/*
+ * 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.core.integtestsupport.legacy;
+
+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.core.integtestsupport.legacy.sample.domain.Country;
+import org.apache.isis.core.integtestsupport.legacy.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/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/MemberReadTest.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/MemberReadTest.java b/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/MemberReadTest.java
new file mode 100644
index 0000000..17a39b0
--- /dev/null
+++ b/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/MemberReadTest.java
@@ -0,0 +1,93 @@
+/*
+ * 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.core.integtestsupport.legacy;
+
+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.core.integtestsupport.legacy.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/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/ObjectImmutableTest.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/ObjectImmutableTest.java b/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/ObjectImmutableTest.java
new file mode 100644
index 0000000..8addec2
--- /dev/null
+++ b/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/ObjectImmutableTest.java
@@ -0,0 +1,87 @@
+/*
+ * 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.core.integtestsupport.legacy;
+
+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/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/SaveObjectsTest.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/SaveObjectsTest.java b/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/SaveObjectsTest.java
new file mode 100644
index 0000000..066cfaa
--- /dev/null
+++ b/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/SaveObjectsTest.java
@@ -0,0 +1,107 @@
+/*
+ * 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.core.integtestsupport.legacy;
+
+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.integtestsupport.legacy.sample.domain.Customer;
+import org.apache.isis.core.progmodel.facets.object.validate.method.ValidateObjectFacetViaValidateMethod;
+
+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/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/TitleTest.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/TitleTest.java b/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/TitleTest.java
new file mode 100644
index 0000000..4586751
--- /dev/null
+++ b/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/TitleTest.java
@@ -0,0 +1,33 @@
+/*
+ * 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.core.integtestsupport.legacy;
+
+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/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/ViewObjectTest.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/ViewObjectTest.java b/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/ViewObjectTest.java
new file mode 100644
index 0000000..492522f
--- /dev/null
+++ b/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/ViewObjectTest.java
@@ -0,0 +1,91 @@
+/*
+ * 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.core.integtestsupport.legacy;
+
+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.core.integtestsupport.legacy.sample.domain.Country;
+import org.apache.isis.core.integtestsupport.legacy.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/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/domain/Country.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/domain/Country.java b/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/domain/Country.java
new file mode 100644
index 0000000..8cb5d0b
--- /dev/null
+++ b/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/domain/Country.java
@@ -0,0 +1,154 @@
+/*
+ * 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.core.integtestsupport.legacy.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/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/domain/Customer.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/domain/Customer.java b/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/domain/Customer.java
new file mode 100644
index 0000000..fc2e7bc
--- /dev/null
+++ b/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/domain/Customer.java
@@ -0,0 +1,777 @@
+/*
+ * 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.core.integtestsupport.legacy.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/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/domain/Order.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/domain/Order.java b/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/domain/Order.java
new file mode 100644
index 0000000..ab5875f
--- /dev/null
+++ b/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/domain/Order.java
@@ -0,0 +1,184 @@
+/*
+ * 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.core.integtestsupport.legacy.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/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/domain/Product.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/domain/Product.java b/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/domain/Product.java
new file mode 100644
index 0000000..afc7160
--- /dev/null
+++ b/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/domain/Product.java
@@ -0,0 +1,185 @@
+/*
+ * 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.core.integtestsupport.legacy.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/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/fixtures/CountriesFixture.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/fixtures/CountriesFixture.java b/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/fixtures/CountriesFixture.java
new file mode 100644
index 0000000..7816567
--- /dev/null
+++ b/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/fixtures/CountriesFixture.java
@@ -0,0 +1,64 @@
+/*
+ * 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.core.integtestsupport.legacy.sample.fixtures;
+
+import org.apache.log4j.Logger;
+
+import org.apache.isis.applib.fixtures.AbstractFixture;
+import org.apache.isis.core.integtestsupport.legacy.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/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/fixtures/CustomerOrdersFixture.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/fixtures/CustomerOrdersFixture.java b/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/fixtures/CustomerOrdersFixture.java
new file mode 100644
index 0000000..e4f75dc
--- /dev/null
+++ b/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/fixtures/CustomerOrdersFixture.java
@@ -0,0 +1,106 @@
+/*
+ * 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.core.integtestsupport.legacy.sample.fixtures;
+
+import org.apache.log4j.Logger;
+
+import org.apache.isis.applib.fixtures.AbstractFixture;
+import org.apache.isis.core.integtestsupport.legacy.sample.domain.Customer;
+import org.apache.isis.core.integtestsupport.legacy.sample.domain.Product;
+import org.apache.isis.core.integtestsupport.legacy.sample.service.CustomerRepository;
+import org.apache.isis.core.integtestsupport.legacy.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/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/fixtures/CustomersFixture.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/fixtures/CustomersFixture.java b/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/fixtures/CustomersFixture.java
new file mode 100644
index 0000000..037d684
--- /dev/null
+++ b/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/fixtures/CustomersFixture.java
@@ -0,0 +1,88 @@
+/*
+ * 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.core.integtestsupport.legacy.sample.fixtures;
+
+import org.apache.log4j.Logger;
+
+import org.apache.isis.applib.fixtures.AbstractFixture;
+import org.apache.isis.core.integtestsupport.legacy.sample.domain.Country;
+import org.apache.isis.core.integtestsupport.legacy.sample.service.CountryRepository;
+import org.apache.isis.core.integtestsupport.legacy.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/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/fixtures/JoeBloggsFixture.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/fixtures/JoeBloggsFixture.java b/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/fixtures/JoeBloggsFixture.java
new file mode 100644
index 0000000..76bf757
--- /dev/null
+++ b/core/integtestsupport/src/test/java/org/apache/isis/core/integtestsupport/legacy/sample/fixtures/JoeBloggsFixture.java
@@ -0,0 +1,30 @@
+/*
+ * 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.core.integtestsupport.legacy.sample.fixtures;
+
+import org.apache.isis.applib.fixtures.LogonFixture;
+
+public class JoeBloggsFixture extends LogonFixture {
+
+ public JoeBloggsFixture() {
+ super("jbloggs");
+ }
+
+}
[4/5] ISIS-409: junit viewer moved up to core...
Posted by da...@apache.org.
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;
- }
-
-}
[5/5] git commit: ISIS-409: junit viewer moved up to core...
Posted by da...@apache.org.
ISIS-409: junit viewer moved up to core...
... in the integtestsupport module
Have put it into a 'legacy' subpackage, since will probably be
removed in the future in preference to the other stuff in integtestsupport.
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/da47b564
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/da47b564
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/da47b564
Branch: refs/heads/master
Commit: da47b564a617b52d8cc803623a3ef9371ae0f1c2
Parents: 55f931a
Author: Dan Haywood <da...@apache.org>
Authored: Mon May 20 13:46:04 2013 +0100
Committer: Dan Haywood <da...@apache.org>
Committed: Mon May 20 13:46:04 2013 +0100
----------------------------------------------------------------------
.../apache/isis/viewer/junit/Authenticator.java | 32 -
.../org/apache/isis/viewer/junit/Authorizor.java | 32 -
.../org/apache/isis/viewer/junit/ConfigDir.java | 36 -
.../java/org/apache/isis/viewer/junit/Fixture.java | 33 -
.../org/apache/isis/viewer/junit/Fixtures.java | 33 -
.../apache/isis/viewer/junit/IsisTestRunner.java | 221 ----
.../org/apache/isis/viewer/junit/Persistor.java | 32 -
.../java/org/apache/isis/viewer/junit/Service.java | 33 -
.../org/apache/isis/viewer/junit/Services.java | 33 -
.../viewer/junit/internal/AnnotationInstaller.java | 96 --
.../internal/FixtureInstallerAnnotatedClass.java | 88 --
.../IsisSystemUsingInstallersWithinJunit.java | 77 --
.../internal/ServicesInstallerAnnotatedClass.java | 68 --
.../org/apache/isis/viewer/junit/AbstractTest.java | 132 ---
.../isis/viewer/junit/DefaultAndChoicesTest.java | 42 -
.../isis/viewer/junit/InteractionListenerTest.java | 54 -
.../isis/viewer/junit/MemberDisabledTest.java | 131 ---
.../apache/isis/viewer/junit/MemberHiddenTest.java | 357 -------
.../isis/viewer/junit/MemberInvalidTest.java | 189 ----
.../apache/isis/viewer/junit/MemberModifyTest.java | 223 -----
.../apache/isis/viewer/junit/MemberReadTest.java | 93 --
.../isis/viewer/junit/ObjectImmutableTest.java | 87 --
.../apache/isis/viewer/junit/SaveObjectsTest.java | 107 --
.../org/apache/isis/viewer/junit/TitleTest.java | 33 -
.../apache/isis/viewer/junit/ViewObjectTest.java | 91 --
.../isis/viewer/junit/sample/domain/Country.java | 154 ---
.../isis/viewer/junit/sample/domain/Customer.java | 777 ---------------
.../isis/viewer/junit/sample/domain/Order.java | 184 ----
.../isis/viewer/junit/sample/domain/Product.java | 185 ----
.../junit/sample/fixtures/CountriesFixture.java | 64 --
.../sample/fixtures/CustomerOrdersFixture.java | 106 --
.../junit/sample/fixtures/CustomersFixture.java | 88 --
.../junit/sample/fixtures/JoeBloggsFixture.java | 30 -
.../junit/sample/fixtures/ProductsFixture.java | 72 --
.../junit/sample/service/CountryRepository.java | 80 --
.../junit/sample/service/CustomerRepository.java | 116 ---
.../junit/sample/service/OrderRepository.java | 67 --
.../junit/sample/service/ProductRepository.java | 103 --
component/viewer/junit/tck/pom.xml | 12 +-
.../tck/src/test/java/junit/AbstractTest.java | 8 +-
.../junit/todo/ScalarEntityRepositoryTest.java | 4 +-
.../src/test/java/junit/todo/ScalarEntityTest.java | 4 +-
core/integtestsupport/pom.xml | 7 +
.../integtestsupport/legacy/Authenticator.java | 32 +
.../core/integtestsupport/legacy/Authorizor.java | 32 +
.../core/integtestsupport/legacy/ConfigDir.java | 36 +
.../isis/core/integtestsupport/legacy/Fixture.java | 33 +
.../core/integtestsupport/legacy/Fixtures.java | 33 +
.../integtestsupport/legacy/IsisTestRunner.java | 221 ++++
.../core/integtestsupport/legacy/Persistor.java | 32 +
.../isis/core/integtestsupport/legacy/Service.java | 33 +
.../core/integtestsupport/legacy/Services.java | 33 +
.../legacy/components/AnnotationInstaller.java | 96 ++
.../components/FixtureInstallerAnnotatedClass.java | 88 ++
.../IsisSystemUsingInstallersWithinJunit.java | 77 ++
.../ServicesInstallerAnnotatedClass.java | 68 ++
.../core/integtestsupport/legacy/AbstractTest.java | 132 +++
.../legacy/DefaultAndChoicesTest.java | 42 +
.../legacy/InteractionListenerTest.java | 54 +
.../legacy/MemberDisabledTest.java | 131 +++
.../integtestsupport/legacy/MemberHiddenTest.java | 357 +++++++
.../integtestsupport/legacy/MemberInvalidTest.java | 189 ++++
.../integtestsupport/legacy/MemberModifyTest.java | 223 +++++
.../integtestsupport/legacy/MemberReadTest.java | 93 ++
.../legacy/ObjectImmutableTest.java | 87 ++
.../integtestsupport/legacy/SaveObjectsTest.java | 107 ++
.../core/integtestsupport/legacy/TitleTest.java | 33 +
.../integtestsupport/legacy/ViewObjectTest.java | 91 ++
.../legacy/sample/domain/Country.java | 154 +++
.../legacy/sample/domain/Customer.java | 777 +++++++++++++++
.../legacy/sample/domain/Order.java | 184 ++++
.../legacy/sample/domain/Product.java | 185 ++++
.../legacy/sample/fixtures/CountriesFixture.java | 64 ++
.../sample/fixtures/CustomerOrdersFixture.java | 106 ++
.../legacy/sample/fixtures/CustomersFixture.java | 88 ++
.../legacy/sample/fixtures/JoeBloggsFixture.java | 30 +
.../legacy/sample/fixtures/ProductsFixture.java | 72 ++
.../legacy/sample/service/CountryRepository.java | 80 ++
.../legacy/sample/service/CustomerRepository.java | 116 +++
.../legacy/sample/service/OrderRepository.java | 67 ++
.../legacy/sample/service/ProductRepository.java | 103 ++
core/pom.xml | 2 +-
example/application/claims/pom.xml | 9 -
example/application/claims/viewer-dnd/pom.xml | 18 +-
.../isis/example/claims/junit/AbstractTest.java | 6 +-
.../isis/example/claims/junit/ClaimSubmitTest.java | 4 +-
.../isis/example/claims/junit/NewClaimTest.java | 4 +-
.../application/quickstart_dnd_junit_bdd/pom.xml | 9 -
.../quickstart_dnd_junit_bdd/tests-junit/pom.xml | 11 +-
.../src/test/java/junit/AbstractTest.java | 8 +-
.../java/junit/todo/ToDoItemRepositoryTest.java | 4 +-
.../src/test/java/junit/todo/ToDoItemTest.java | 4 +-
pom.xml | 1 -
93 files changed, 4437 insertions(+), 4436 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/Authenticator.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/Authenticator.java b/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/Authenticator.java
deleted file mode 100644
index 910546b..0000000
--- a/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/Authenticator.java
+++ /dev/null
@@ -1,32 +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 java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Target(ElementType.TYPE)
-@Inherited
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Authenticator {
- Class<?> value();
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/Authorizor.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/Authorizor.java b/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/Authorizor.java
deleted file mode 100644
index ee0f5b2..0000000
--- a/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/Authorizor.java
+++ /dev/null
@@ -1,32 +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 java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Target(ElementType.TYPE)
-@Inherited
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Authorizor {
- Class<?> value();
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/ConfigDir.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/ConfigDir.java b/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/ConfigDir.java
deleted file mode 100644
index a1e70f3..0000000
--- a/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/ConfigDir.java
+++ /dev/null
@@ -1,36 +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 java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * The location of the <tt>config</tt> directory, relative to the base.
- */
-@Target(ElementType.TYPE)
-@Inherited
-@Retention(RetentionPolicy.RUNTIME)
-public @interface ConfigDir {
- String value();
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/Fixture.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/Fixture.java b/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/Fixture.java
deleted file mode 100644
index 2909009..0000000
--- a/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/Fixture.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 java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Target(ElementType.TYPE)
-@Inherited
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Fixture {
- Class<?> value();
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/Fixtures.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/Fixtures.java b/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/Fixtures.java
deleted file mode 100644
index 3d33ec7..0000000
--- a/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/Fixtures.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 java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Target(ElementType.TYPE)
-@Inherited
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Fixtures {
- Fixture[] value();
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/IsisTestRunner.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/IsisTestRunner.java b/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/IsisTestRunner.java
deleted file mode 100644
index a795b0b..0000000
--- a/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/IsisTestRunner.java
+++ /dev/null
@@ -1,221 +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 java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-import org.jmock.Mockery;
-import org.junit.internal.runners.InitializationError;
-import org.junit.internal.runners.JUnit4ClassRunner;
-import org.junit.internal.runners.MethodRoadie;
-import org.junit.internal.runners.TestClass;
-import org.junit.internal.runners.TestMethod;
-import org.junit.runner.Description;
-import org.junit.runner.notification.Failure;
-import org.junit.runner.notification.RunNotifier;
-
-import org.apache.isis.applib.fixtures.LogonFixture;
-import org.apache.isis.core.commons.authentication.AuthenticationSession;
-import org.apache.isis.core.commons.config.IsisConfigurationBuilder;
-import org.apache.isis.core.commons.config.IsisConfigurationBuilderDefault;
-import org.apache.isis.core.metamodel.services.ServicesInjectorSpi;
-import org.apache.isis.core.runtime.authentication.AuthenticationRequest;
-import org.apache.isis.core.runtime.authentication.exploration.AuthenticationRequestExploration;
-import org.apache.isis.core.runtime.fixtures.authentication.AuthenticationRequestLogonFixture;
-import org.apache.isis.core.runtime.installers.InstallerLookupDefault;
-import org.apache.isis.core.runtime.system.DeploymentType;
-import org.apache.isis.core.runtime.system.SystemConstants;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
-import org.apache.isis.core.runtime.system.transaction.IsisTransactionManager;
-import org.apache.isis.viewer.junit.internal.IsisSystemUsingInstallersWithinJunit;
-
-/**
- * Copied from JMock, and with the same support.
- *
- */
-public class IsisTestRunner extends JUnit4ClassRunner {
-
- private final Field mockeryField;
-
- /**
- * Only used during object construction.
- */
- public IsisTestRunner(final Class<?> testClass) throws InitializationError {
- super(testClass);
-
- // JMock initialization, adapted to allow for no mockery field.
- mockeryField = findFieldAndMakeAccessible(testClass, Mockery.class);
- }
-
- private static String getConfigDir(final Class<?> javaClass) {
- final ConfigDir fixturesAnnotation = javaClass.getAnnotation(ConfigDir.class);
- if (fixturesAnnotation != null) {
- return fixturesAnnotation.value();
- }
- return null;
- }
-
- @Override
- protected void invokeTestMethod(final Method method, final RunNotifier notifier) {
-
- final TestClass testClass = getTestClass();
- final String configDirIfAny = getConfigDir(testClass.getJavaClass());
-
- final Description description = methodDescription(method);
-
- final IsisConfigurationBuilder isisConfigurationBuilder = new IsisConfigurationBuilderDefault(configDirIfAny);
- isisConfigurationBuilder.add(SystemConstants.NOSPLASH_KEY, "" + true); // switch
- // off
- // splash
-
- final InstallerLookupDefault installerLookup = new InstallerLookupDefault();
- isisConfigurationBuilder.injectInto(installerLookup);
- installerLookup.init();
-
- IsisSystemUsingInstallersWithinJunit system = null;
- AuthenticationSession session = null;
- try {
- // init the system; cf similar code in Isis and
- // IsisServletContextInitializer
- final DeploymentType deploymentType = DeploymentType.PROTOTYPE;
-
- // TODO: replace with regular IsisSystem and remove this subclass.
- system = new IsisSystemUsingInstallersWithinJunit(deploymentType, installerLookup, testClass);
-
- system.init();
-
- // specific to this bootstrap mechanism
- AuthenticationRequest request;
- final LogonFixture logonFixture = system.getFixturesInstaller().getLogonFixture();
- if (logonFixture != null) {
- request = new AuthenticationRequestLogonFixture(logonFixture);
- } else {
- request = new AuthenticationRequestExploration(logonFixture);
- }
- session = IsisContext.getAuthenticationManager().authenticate(request);
-
- IsisContext.openSession(session);
- getTransactionManager().startTransaction();
-
- final Object test = createTest();
- getServicesInjector().injectServicesInto(test);
-
- final TestMethod testMethod = wrapMethod(method);
- new MethodRoadie(test, testMethod, notifier, description).run();
-
- getTransactionManager().endTransaction();
-
- } catch (final InvocationTargetException e) {
- testAborted(notifier, description, e.getCause());
- getTransactionManager().abortTransaction();
- return;
- } catch (final Exception e) {
- testAborted(notifier, description, e);
- return;
- } finally {
- if (system != null) {
- if (session != null) {
- IsisContext.closeSession();
- }
- system.shutdown();
- }
- }
- }
-
- private void testAborted(final RunNotifier notifier, final Description description, final Throwable e) {
- notifier.fireTestStarted(description);
- notifier.fireTestFailure(new Failure(description, e));
- notifier.fireTestFinished(description);
- }
-
- /**
- * Taken from JMock's runner.
- */
- @Override
- protected TestMethod wrapMethod(final Method method) {
- return new TestMethod(method, getTestClass()) {
- @Override
- public void invoke(final Object testFixture) throws IllegalAccessException, InvocationTargetException {
-
- super.invoke(testFixture);
-
- if (mockeryField != null) {
- mockeryOf(testFixture).assertIsSatisfied();
- }
- }
- };
- }
-
- /**
- * JMock code.
- *
- * @param test
- * @return
- */
- protected Mockery mockeryOf(final Object test) {
- if (mockeryField == null) {
- return null;
- }
- try {
- final Mockery mockery = (Mockery) mockeryField.get(test);
- if (mockery == null) {
- throw new IllegalStateException(String.format("Mockery named '%s' is null", mockeryField.getName()));
- }
- return mockery;
- } catch (final IllegalAccessException e) {
- throw new IllegalStateException(String.format("cannot get value of field %s", mockeryField.getName()), e);
- }
- }
-
- /**
- * Adapted from JMock code.
- */
- static Field findFieldAndMakeAccessible(final Class<?> testClass, final Class<?> clazz) throws InitializationError {
- for (Class<?> c = testClass; c != Object.class; c = c.getSuperclass()) {
- for (final Field field : c.getDeclaredFields()) {
- if (clazz.isAssignableFrom(field.getType())) {
- field.setAccessible(true);
- return field;
- }
- }
- }
- return null;
- }
-
- // /////////////////////////////////////////////////////
- // Dependencies (from context)
- // /////////////////////////////////////////////////////
-
- private static PersistenceSession getPersistenceSession() {
- return IsisContext.getPersistenceSession();
- }
-
- private static ServicesInjectorSpi getServicesInjector() {
- return getPersistenceSession().getServicesInjector();
- }
-
- private static IsisTransactionManager getTransactionManager() {
- return getPersistenceSession().getTransactionManager();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/Persistor.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/Persistor.java b/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/Persistor.java
deleted file mode 100644
index c7d59e3..0000000
--- a/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/Persistor.java
+++ /dev/null
@@ -1,32 +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 java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Target(ElementType.TYPE)
-@Inherited
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Persistor {
- Class<?> value();
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/Service.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/Service.java b/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/Service.java
deleted file mode 100644
index 6cc809c..0000000
--- a/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/Service.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 java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Target(ElementType.TYPE)
-@Inherited
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Service {
- Class<?> value();
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/Services.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/Services.java b/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/Services.java
deleted file mode 100644
index 81b09f5..0000000
--- a/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/Services.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 java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Target(ElementType.TYPE)
-@Inherited
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Services {
- Service[] value();
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/internal/AnnotationInstaller.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/internal/AnnotationInstaller.java b/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/internal/AnnotationInstaller.java
deleted file mode 100644
index 7c78163..0000000
--- a/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/internal/AnnotationInstaller.java
+++ /dev/null
@@ -1,96 +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.internal;
-
-import org.apache.isis.core.objectstore.InMemoryPersistenceMechanismInstaller;
-import org.apache.isis.core.runtime.authentication.AuthenticationManagerInstaller;
-import org.apache.isis.core.runtime.authorization.AuthorizationManagerInstaller;
-import org.apache.isis.core.runtime.installerregistry.installerapi.PersistenceMechanismInstaller;
-import org.apache.isis.core.security.authentication.BypassAuthenticationManagerInstaller;
-import org.apache.isis.core.security.authorization.BypassAuthorizationManagerInstaller;
-import org.apache.isis.viewer.junit.Authenticator;
-import org.apache.isis.viewer.junit.Authorizor;
-import org.apache.isis.viewer.junit.Persistor;
-
-public class AnnotationInstaller {
-
- /**
- * Should be called prior to installing; typically called immediately after
- * instantiation.
- *
- * <p>
- * Note: an alternative design would be to have a 1-arg constructor, but the
- * convention for installers is to make them no-arg.
- */
- // {{ AuthenticationManagerInstaller
- public AuthenticationManagerInstaller addAuthenticatorAnnotatedOn(final Class<?> javaClass) throws InstantiationException, IllegalAccessException {
- final Authenticator authenticatorAnnotation = javaClass.getAnnotation(Authenticator.class);
- if (authenticatorAnnotation != null) {
- return addAuthenticatorRepresentedBy(authenticatorAnnotation);
- } else {
- return new BypassAuthenticationManagerInstaller();
- }
-
- }
-
- private AuthenticationManagerInstaller addAuthenticatorRepresentedBy(final Authenticator authenticatorAnnotation) throws InstantiationException, IllegalAccessException {
- final Class<?> fixtureClass = authenticatorAnnotation.value();
- return (AuthenticationManagerInstaller) fixtureClass.newInstance();
- }
-
- // }}
-
- // {{ AuthorizationManagerInstaller
- public AuthorizationManagerInstaller addAuthorizerAnnotatedOn(final Class<?> javaClass) throws InstantiationException, IllegalAccessException {
- final Authorizor authorizorAnnotation = javaClass.getAnnotation(Authorizor.class);
- if (authorizorAnnotation != null) {
- return addAuthorizerRepresentedBy(authorizorAnnotation);
- } else {
- return new BypassAuthorizationManagerInstaller();
- }
-
- }
-
- private AuthorizationManagerInstaller addAuthorizerRepresentedBy(final Authorizor authorizorAnnotation) throws InstantiationException, IllegalAccessException {
- final Class<?> fixtureClass = authorizorAnnotation.value();
- return (AuthorizationManagerInstaller) fixtureClass.newInstance();
- }
-
- // }}
-
- // {{ PersistenceMechanismInstaller
- public PersistenceMechanismInstaller addPersistorAnnotatedOn(final Class<?> javaClass) throws InstantiationException, IllegalAccessException {
- final Persistor annotation = javaClass.getAnnotation(Persistor.class);
- if (annotation != null) {
- return addPersistorRepresentedBy(annotation);
- } else {
- return new InMemoryPersistenceMechanismInstaller();
- }
-
- }
-
- private PersistenceMechanismInstaller addPersistorRepresentedBy(final Persistor annotation) throws InstantiationException, IllegalAccessException {
- final Class<?> fixtureClass = annotation.value();
- return (PersistenceMechanismInstaller) fixtureClass.newInstance();
- }
- // }}
-
- // new InMemoryUserProfileStoreInstaller();
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/internal/FixtureInstallerAnnotatedClass.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/internal/FixtureInstallerAnnotatedClass.java b/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/internal/FixtureInstallerAnnotatedClass.java
deleted file mode 100644
index d37709e..0000000
--- a/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/internal/FixtureInstallerAnnotatedClass.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.internal;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.isis.core.runtime.fixtures.FixturesInstallerAbstract;
-import org.apache.isis.core.runtime.fixtures.FixturesInstallerDelegate;
-import org.apache.isis.viewer.junit.Fixture;
-import org.apache.isis.viewer.junit.Fixtures;
-
-public class FixtureInstallerAnnotatedClass extends FixturesInstallerAbstract {
-
- private final List<Object> fixtures = new ArrayList<Object>();
-
- /**
- * @see #addFixturesAnnotatedOn(Class)
- */
- public FixtureInstallerAnnotatedClass() {
- super("annotated");
- }
-
- // ///////////////////////////////////////////
- // Hook method
- // ///////////////////////////////////////////
-
- /**
- * Just copies the fixtures added using
- * {@link #addFixturesAnnotatedOn(Class)} into the delegate.
- */
- @Override
- protected void addFixturesTo(final FixturesInstallerDelegate delegate) {
- for (final Object fixture : fixtures) {
- delegate.addFixture(fixture);
- }
- }
-
- // ///////////////////////////////////////////
- // addFixturesAnnotatedOn (not API)
- // ///////////////////////////////////////////
-
- /**
- * Should be called prior to installing; typically called immediately after
- * instantiation.
- *
- * <p>
- * Note: an alternative design would be to have a 1-arg constructor, but the
- * convention for installers is to make them no-arg.
- */
- public void addFixturesAnnotatedOn(final Class<?> javaClass) throws InstantiationException, IllegalAccessException {
- final Fixtures fixturesAnnotation = javaClass.getAnnotation(Fixtures.class);
- if (fixturesAnnotation != null) {
- final Fixture[] fixtureAnnotations = fixturesAnnotation.value();
- for (final Fixture fixtureAnnotation : fixtureAnnotations) {
- addFixtureRepresentedBy(fixtureAnnotation, fixtures);
- }
- }
-
- final Fixture fixtureAnnotation = javaClass.getAnnotation(Fixture.class);
- if (fixtureAnnotation != null) {
- addFixtureRepresentedBy(fixtureAnnotation, fixtures);
- }
- }
-
- private void addFixtureRepresentedBy(final Fixture fixtureAnnotation, final List<Object> fixtures) throws InstantiationException, IllegalAccessException {
- final Class<?> fixtureClass = fixtureAnnotation.value();
- fixtures.add(fixtureClass.newInstance());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/internal/IsisSystemUsingInstallersWithinJunit.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/internal/IsisSystemUsingInstallersWithinJunit.java b/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/internal/IsisSystemUsingInstallersWithinJunit.java
deleted file mode 100644
index 0c31c48..0000000
--- a/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/internal/IsisSystemUsingInstallersWithinJunit.java
+++ /dev/null
@@ -1,77 +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.internal;
-
-import org.junit.internal.runners.TestClass;
-
-import org.apache.isis.core.commons.exceptions.IsisException;
-import org.apache.isis.core.profilestore.InMemoryUserProfileStoreInstaller;
-import org.apache.isis.core.runtime.installerregistry.InstallerLookup;
-import org.apache.isis.core.runtime.system.DeploymentType;
-import org.apache.isis.core.runtime.systemusinginstallers.IsisSystemUsingInstallers;
-
-public class IsisSystemUsingInstallersWithinJunit extends IsisSystemUsingInstallers {
-
- private final TestClass testClass;
-
- public IsisSystemUsingInstallersWithinJunit(final DeploymentType deploymentType, final InstallerLookup installerLookup, final TestClass testClass) {
- super(deploymentType, installerLookup);
- installerLookup.getConfigurationBuilder().add("isis.deploymentType", deploymentType.nameLowerCase());
-
- this.testClass = testClass;
-
- final AnnotationInstaller installer = new AnnotationInstaller();
-
- try {
- setAuthenticationInstaller(getInstallerLookup().injectDependenciesInto(installer.addAuthenticatorAnnotatedOn(this.testClass.getJavaClass())));
-
- setAuthorizationInstaller(getInstallerLookup().injectDependenciesInto(installer.addAuthorizerAnnotatedOn(this.testClass.getJavaClass())));
-
- setPersistenceMechanismInstaller(getInstallerLookup().injectDependenciesInto(installer.addPersistorAnnotatedOn(this.testClass.getJavaClass())));
-
- setUserProfileStoreInstaller(getInstallerLookup().injectDependenciesInto(new InMemoryUserProfileStoreInstaller()));
-
- // fixture installer
- final FixtureInstallerAnnotatedClass fixtureInstaller = new FixtureInstallerAnnotatedClass();
- fixtureInstaller.addFixturesAnnotatedOn(this.testClass.getJavaClass());
- setFixtureInstaller(fixtureInstaller);
- } catch (final InstantiationException e) {
- throw new IsisException(e);
- } catch (final IllegalAccessException e) {
- throw new IsisException(e);
- }
-
- // services installer
- final ServicesInstallerAnnotatedClass servicesInstaller = new ServicesInstallerAnnotatedClass();
- try {
- servicesInstaller.addServicesAnnotatedOn(this.testClass.getJavaClass());
- } catch (final InstantiationException e) {
- throw new IsisException(e);
- } catch (final IllegalAccessException e) {
- throw new IsisException(e);
- }
- setServicesInstaller(servicesInstaller);
- }
-
- public TestClass getTestClass() {
- return testClass;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/internal/ServicesInstallerAnnotatedClass.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/internal/ServicesInstallerAnnotatedClass.java b/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/internal/ServicesInstallerAnnotatedClass.java
deleted file mode 100644
index 646df12..0000000
--- a/component/viewer/junit/impl/src/main/java/org/apache/isis/viewer/junit/internal/ServicesInstallerAnnotatedClass.java
+++ /dev/null
@@ -1,68 +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.internal;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.isis.core.runtime.services.ServicesInstallerAbstract;
-import org.apache.isis.viewer.junit.Service;
-import org.apache.isis.viewer.junit.Services;
-
-public class ServicesInstallerAnnotatedClass extends ServicesInstallerAbstract {
-
- public ServicesInstallerAnnotatedClass() {
- super("annotated");
- }
-
- public void addServicesAnnotatedOn(final Class<?> javaClass) throws InstantiationException, IllegalAccessException {
- final List<Object> services = new ArrayList<Object>();
- addServicesAnnotatedOn(javaClass, services);
- addServices(services);
- }
-
- private void addServicesAnnotatedOn(final Class<?> testClass, final List<Object> services) throws InstantiationException, IllegalAccessException {
- final Services servicesAnnotation = testClass.getAnnotation(Services.class);
- if (servicesAnnotation != null) {
- final Service[] serviceAnnotations = servicesAnnotation.value();
- for (final Service serviceAnnotation : serviceAnnotations) {
- addServiceRepresentedBy(serviceAnnotation, services);
- }
- }
-
- final Service serviceAnnotation = testClass.getAnnotation(Service.class);
- if (serviceAnnotation != null) {
- addServiceRepresentedBy(serviceAnnotation, services);
- }
- }
-
- private void addServiceRepresentedBy(final Service serviceAnnotation, final List<Object> services) throws InstantiationException, IllegalAccessException {
- final Class<?> serviceClass = serviceAnnotation.value();
- // there's no need to unravel any Collections of services,
- // because the ServiceLoader will do it for us later.
- services.add(serviceClass.newInstance());
- }
-
- @Override
- public List<Class<?>> getTypes() {
- return listOf(List.class); // ie List<Object.class>, of services
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/AbstractTest.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/AbstractTest.java b/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/AbstractTest.java
deleted file mode 100644
index 85a0027..0000000
--- a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/AbstractTest.java
+++ /dev/null
@@ -1,132 +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 org.junit.After;
-import org.junit.Before;
-import org.junit.runner.RunWith;
-
-import org.apache.isis.applib.DomainObjectContainer;
-import org.apache.isis.applib.services.wrapper.WrapperFactory;
-import org.apache.isis.core.wrapper.WrapperFactoryDefault;
-import org.apache.isis.viewer.junit.sample.domain.Country;
-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.fixtures.CountriesFixture;
-import org.apache.isis.viewer.junit.sample.fixtures.CustomerOrdersFixture;
-import org.apache.isis.viewer.junit.sample.fixtures.CustomersFixture;
-import org.apache.isis.viewer.junit.sample.fixtures.ProductsFixture;
-import org.apache.isis.viewer.junit.sample.service.CountryRepository;
-import org.apache.isis.viewer.junit.sample.service.CustomerRepository;
-import org.apache.isis.viewer.junit.sample.service.OrderRepository;
-import org.apache.isis.viewer.junit.sample.service.ProductRepository;
-
-@RunWith(IsisTestRunner.class)
-@Fixtures({ @Fixture(CountriesFixture.class), @Fixture(ProductsFixture.class), @Fixture(CustomersFixture.class), @Fixture(CustomerOrdersFixture.class) })
-@Services({ @Service(CountryRepository.class), @Service(ProductRepository.class), @Service(CustomerRepository.class), @Service(OrderRepository.class), @Service(WrapperFactoryDefault.class) })
-public abstract class AbstractTest {
-
- protected Customer custJsDO;
- protected Customer custJsWO;
-
- protected Product product355DO;
- protected Product product355VO;
-
- protected Product product850DO;
-
- protected Country countryGbrDO;
- protected Country countryGbrVO;
-
- protected Country countryUsaDO;
- protected Country countryAusDO;
-
- private ProductRepository productRepository;
- private CustomerRepository customerRepository;
- private CountryRepository countryRepository;
-
- private DomainObjectContainer domainObjectContainer;
- private WrapperFactory wrapperFactory;
-
- @Before
- public void setUp() {
-
- product355DO = productRepository.findByCode("355-40311");
- product355VO = wrapperFactory.wrap(product355DO);
- product850DO = productRepository.findByCode("850-18003");
-
- countryGbrDO = countryRepository.findByCode("GBR");
- countryGbrVO = wrapperFactory.wrap(countryGbrDO);
-
- countryUsaDO = countryRepository.findByCode("USA");
- countryAusDO = countryRepository.findByCode("AUS");
-
- custJsDO = customerRepository.findByName("Pawson");
- custJsWO = wrapperFactory.wrap(custJsDO);
- }
-
- @After
- public void tearDown() {
- }
-
- // //////////////////////////////////////////////////////
- // Injected.
- // //////////////////////////////////////////////////////
-
- protected WrapperFactory getWrapperFactory() {
- return wrapperFactory;
- }
-
- public void setWrapperFactory(final WrapperFactory headlessViewer) {
- this.wrapperFactory = headlessViewer;
- }
-
- protected DomainObjectContainer getDomainObjectContainer() {
- return domainObjectContainer;
- }
-
- public void setDomainObjectContainer(final DomainObjectContainer domainObjectContainer) {
- this.domainObjectContainer = domainObjectContainer;
- }
-
- protected ProductRepository getProductRepository() {
- return productRepository;
- }
-
- public void setProductRepository(final ProductRepository productRepository) {
- this.productRepository = productRepository;
- }
-
- protected CustomerRepository getCustomerRepository() {
- return customerRepository;
- }
-
- public void setCustomerRepository(final CustomerRepository customerRepository) {
- this.customerRepository = customerRepository;
- }
-
- protected CountryRepository getCountryRepository() {
- return countryRepository;
- }
-
- 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/DefaultAndChoicesTest.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/DefaultAndChoicesTest.java b/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/DefaultAndChoicesTest.java
deleted file mode 100644
index cc90c9d..0000000
--- a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/DefaultAndChoicesTest.java
+++ /dev/null
@@ -1,42 +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.is;
-import static org.junit.Assert.assertThat;
-
-import org.junit.Ignore;
-import org.junit.Test;
-
-public class DefaultAndChoicesTest extends AbstractTest {
-
- @Test
- public void defaults() {
- final Object[] defaultPlaceOrder = custJsWO.defaultPlaceOrder();
- assertThat(defaultPlaceOrder.length, is(2));
- }
-
- @Ignore("not yet tested")
- @Test
- public void choicesDefaults() {
- // not tested.
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/InteractionListenerTest.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/InteractionListenerTest.java b/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/InteractionListenerTest.java
deleted file mode 100644
index 9cb9cd2..0000000
--- a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/InteractionListenerTest.java
+++ /dev/null
@@ -1,54 +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.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.junit.Assert.assertThat;
-
-import org.junit.Test;
-
-import org.apache.isis.applib.events.InteractionEvent;
-import org.apache.isis.applib.events.PropertyAccessEvent;
-import org.apache.isis.applib.services.wrapper.listeners.InteractionAdapter;
-import org.apache.isis.applib.services.wrapper.listeners.InteractionListener;
-import org.apache.isis.viewer.junit.sample.domain.Customer;
-
-public class InteractionListenerTest extends AbstractTest {
-
- @Test
- public void shouldBeAbleToAddListener() {
- final Customer proxiedCustRP = getWrapperFactory().wrap(custJsDO);
- final InteractionEvent[] events = { null };
- final InteractionListener l = new InteractionAdapter() {
- @Override
- public void propertyAccessed(final PropertyAccessEvent ev) {
- events[0] = ev;
- }
- };
- getWrapperFactory().addInteractionListener(l);
-
- proxiedCustRP.getFirstName();
- assertThat(events[0], notNullValue());
- final PropertyAccessEvent ev = (PropertyAccessEvent) events[0];
- assertThat(ev.getMemberNaturalName(), is("First Name"));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/MemberDisabledTest.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/MemberDisabledTest.java b/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/MemberDisabledTest.java
deleted file mode 100644
index 0bb145b..0000000
--- a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/MemberDisabledTest.java
+++ /dev/null
@@ -1,131 +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 java.util.List;
-
-import org.junit.Test;
-
-import org.apache.isis.applib.services.wrapper.DisabledException;
-import org.apache.isis.core.progmodel.facets.members.disabled.annotation.DisabledFacetAnnotation;
-import org.apache.isis.core.progmodel.facets.members.disabled.method.DisableForContextFacetViaMethod;
-import org.apache.isis.viewer.junit.sample.domain.Order;
-
-public class MemberDisabledTest extends AbstractTest {
-
- @Test
- public void whenValueDisabledForValueThenThrowsException() {
- custJsDO.disableFirstName = "cannot alter";
- try {
- custJsWO.setFirstName("Dick");
- fail("Should have thrown exception");
- } catch (final DisabledException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(DisableForContextFacetViaMethod.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("First Name"));
- assertThat(ex.getMessage(), equalTo("cannot alter"));
- }
- }
-
- @Test
- public void whenValueDisabledForNullThenThrowsException() {
- custJsDO.disableFirstName = "cannot alter";
- try {
- custJsWO.setFirstName(null);
- fail("Should have thrown exception");
- } catch (final DisabledException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(DisableForContextFacetViaMethod.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("First Name"));
- assertThat(ex.getMessage(), equalTo("cannot alter"));
- }
- }
-
- @Test
- public void whenAssociationDisabledForReferenceThenThrowsException() {
- custJsDO.disableCountryOfBirth = "cannot alter";
- try {
- custJsWO.setCountryOfBirth(countryUsaDO);
- fail("Should have thrown exception");
- } catch (final DisabledException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(DisableForContextFacetViaMethod.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Country Of Birth"));
- assertThat(ex.getMessage(), equalTo("cannot alter"));
- }
- }
-
- @Test
- public void whenAssociationDisabledForNullThenThrowsException() {
- custJsDO.disableCountryOfBirth = "cannot alter";
- try {
- custJsWO.setCountryOfBirth(null);
- fail("Should have thrown exception");
- } catch (final DisabledException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(DisableForContextFacetViaMethod.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Country Of Birth"));
- assertThat(ex.getMessage(), equalTo("cannot alter"));
- }
- }
-
- @Test
- public void whenCollectionDisabledThenAddToThrowsException() {
- final List<Order> orders = custJsWO.getOrders();
- final Order order = orders.get(0);
- try {
- custJsWO.addToMoreOrders(order);
- fail("Should have thrown exception");
- } catch (final DisabledException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(DisabledFacetAnnotation.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("More Orders"));
- assertThat(ex.getMessage(), equalTo("Always disabled"));
- }
- }
-
- @Test
- public void whenCollectionDisabledThenRemovefromThrowsException() {
- custJsDO.addToVisitedCountries(countryUsaDO);
- custJsDO.disableVisitedCountries = "cannot alter";
- try {
- custJsWO.removeFromVisitedCountries(countryUsaDO);
- fail("Should have thrown exception");
- } catch (final DisabledException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(DisableForContextFacetViaMethod.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Visited Countries"));
- assertThat(ex.getMessage(), equalTo("cannot alter"));
- }
- }
-
- @Test
- public void whenActionDisabledThenThrowsException() {
- custJsDO.disablePlaceOrder = "cannot invoke";
- try {
- custJsWO.placeOrder(product355DO, 3);
- fail("Should have thrown exception");
- } catch (final DisabledException ex) {
- assertThat(ex.getAdvisorClass(), classEqualTo(DisableForContextFacetViaMethod.class));
- assertThat(ex.getIdentifier().getMemberNaturalName(), equalTo("Place Order"));
- assertThat(ex.getMessage(), equalTo("cannot invoke"));
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/MemberHiddenTest.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/MemberHiddenTest.java b/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/MemberHiddenTest.java
deleted file mode 100644
index d8cb0c8..0000000
--- a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/MemberHiddenTest.java
+++ /dev/null
@@ -1,357 +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.HiddenException;
-import org.apache.isis.core.progmodel.facets.members.hidden.annotation.HiddenFacetForMemberAnnotation;
-import org.apache.isis.core.progmodel.facets.members.hidden.forsession.HideForSessionFacetViaMethod;
-import org.apache.isis.core.progmodel.facets.members.hidden.method.HideForContextFacetViaMethod;
-import org.apache.isis.viewer.junit.sample.domain.Country;
-
-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"));
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/da47b564/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/MemberInvalidTest.java
----------------------------------------------------------------------
diff --git a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/MemberInvalidTest.java b/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/MemberInvalidTest.java
deleted file mode 100644
index 3ef955f..0000000
--- a/component/viewer/junit/impl/src/test/java/org/apache/isis/viewer/junit/MemberInvalidTest.java
+++ /dev/null
@@ -1,189 +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.InvalidException;
-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;
-import org.apache.isis.core.progmodel.facets.collections.validate.CollectionValidateRemoveFromFacetViaMethod;
-import org.apache.isis.core.progmodel.facets.properties.validate.PropertyValidateFacetViaMethod;
-import org.apache.isis.core.progmodel.facets.properties.validate.maxlenannot.MaxLengthFacetAnnotationForProperty;
-import org.apache.isis.core.progmodel.facets.properties.validate.regexannot.RegExFacetAnnotationForProperty;
-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");
- }
-
-}