Skip to content

Commit

Permalink
Uses java-11 in naked objects
Browse files Browse the repository at this point in the history
  • Loading branch information
anuragagarwal561994 committed Aug 8, 2020
1 parent b0ac4c1 commit a5038c4
Show file tree
Hide file tree
Showing 17 changed files with 84 additions and 132 deletions.
2 changes: 1 addition & 1 deletion naked-objects/dom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
<ignore/>
</action>
</pluginExecution>
</pluginExecutions>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
/**
* 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.
*/
{
"columns": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@
strategy = javax.jdo.annotations.IdGeneratorStrategy.IDENTITY, column = "id")
@javax.jdo.annotations.Version(strategy = VersionStrategy.VERSION_NUMBER, column = "version")
@javax.jdo.annotations.Queries({
@javax.jdo.annotations.Query(name = "find", language = "JDOQL", value = "SELECT "
@javax.jdo.annotations.Query(name = "find", value = "SELECT "
+ "FROM domainapp.dom.modules.simple.SimpleObject "),
@javax.jdo.annotations.Query(name = "findByName", language = "JDOQL", value = "SELECT "
@javax.jdo.annotations.Query(name = "findByName", value = "SELECT "
+ "FROM domainapp.dom.modules.simple.SimpleObject " + "WHERE name.indexOf(:name) >= 0 ")})
@javax.jdo.annotations.Unique(name = "SimpleObject_name_UNQ", members = {"name"})
@DomainObject
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
/**
* 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.
*/
{
"columns": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ public class SimpleObjectTest {
SimpleObject simpleObject;

@Before
public void setUp() throws Exception {
public void setUp() {
simpleObject = new SimpleObject();
}

@Test
public void testName() throws Exception {
public void testName() {
// given
String name = "Foobar";
assertNull(simpleObject.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ public class SimpleObjectsTest {
SimpleObjects simpleObjects;

@Before
public void setUp() throws Exception {
public void setUp() {
simpleObjects = new SimpleObjects();
simpleObjects.container = mockContainer;
}

@Test
public void testCreate() throws Exception {
public void testCreate() {

// given
final SimpleObject simpleObject = new SimpleObject();
Expand All @@ -85,7 +85,7 @@ public void testCreate() throws Exception {
}

@Test
public void testListAll() throws Exception {
public void testListAll() {

// given
final List<SimpleObject> all = Lists.newArrayList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ public SimpleObject getSimpleObject() {

@Override
protected void execute(final ExecutionContext ec) {

String paramName = checkParam("name", ec, String.class);
var paramName = checkParam("name", ec, String.class);

this.simpleObject = wrap(simpleObjects).create(paramName);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import domainapp.dom.modules.simple.SimpleObject;
import domainapp.fixture.modules.simple.SimpleObjectCreate;
import domainapp.fixture.modules.simple.SimpleObjectsTearDown;
import java.util.Collections;
import java.util.List;
import org.apache.isis.applib.fixturescripts.FixtureScript;

Expand All @@ -37,8 +36,18 @@
*/
public class RecreateSimpleObjects extends FixtureScript {

public final List<String> names = Collections.unmodifiableList(List.of("Foo", "Bar", "Baz",
"Frodo", "Froyo", "Fizz", "Bip", "Bop", "Bang", "Boo"));
public final List<String> names = List.of(
"Foo",
"Bar",
"Baz",
"Frodo",
"Froyo",
"Fizz",
"Bip",
"Bop",
"Bang",
"Boo"
);

// region > number (optional input)
private Integer number;
Expand Down Expand Up @@ -77,7 +86,7 @@ public List<SimpleObject> getSimpleObjects() {
protected void execute(final ExecutionContext ec) {

// defaults
final int paramNumber = defaultParam("number", ec, 3);
final var paramNumber = defaultParam("number", ec, 3);

// validate
if (paramNumber < 0 || paramNumber > names.size()) {
Expand All @@ -90,8 +99,8 @@ protected void execute(final ExecutionContext ec) {
//
ec.executeChild(this, new SimpleObjectsTearDown());

for (int i = 0; i < paramNumber; i++) {
final SimpleObjectCreate fs = new SimpleObjectCreate().setName(names.get(i));
for (var i = 0; i < paramNumber; i++) {
final var fs = new SimpleObjectCreate().setName(names.get(i));
ec.executeChild(this, fs.getName(), fs);
simpleObjects.add(fs.getSimpleObject());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

import org.apache.isis.core.commons.config.IsisConfiguration;
import org.apache.isis.core.integtestsupport.IsisSystemForTest;
import org.apache.isis.objectstore.jdo.datanucleus.DataNucleusPersistenceMechanismInstaller;
import org.apache.isis.objectstore.jdo.datanucleus.IsisConfigurationForJdoIntegTests;

/**
Expand All @@ -40,7 +39,7 @@ private SimpleAppSystemInitializer() {
* Init test system
*/
public static void initIsft() {
IsisSystemForTest isft = IsisSystemForTest.getElseNull();
var isft = IsisSystemForTest.getElseNull();
if (isft == null) {
isft = new SimpleAppSystemBuilder().build().setUpSystem();
IsisSystemForTest.set(isft);
Expand All @@ -51,15 +50,13 @@ private static class SimpleAppSystemBuilder extends IsisSystemForTest.Builder {

public SimpleAppSystemBuilder() {
with(testConfiguration());
with(new DataNucleusPersistenceMechanismInstaller());

// services annotated with @DomainService
withServicesIn("domainapp");
}

private static IsisConfiguration testConfiguration() {
final IsisConfigurationForJdoIntegTests testConfiguration =
new IsisConfigurationForJdoIntegTests();
final var testConfiguration = new IsisConfigurationForJdoIntegTests();

testConfiguration.addRegisterEntitiesPackagePrefix("domainapp.dom.modules");
return testConfiguration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,17 @@

package domainapp.integtests.specglue;

import org.apache.isis.core.specsupport.specs.CukeGlueAbstract;

import cucumber.api.java.Before;
import domainapp.fixture.scenarios.RecreateSimpleObjects;
import org.apache.isis.core.specsupport.specs.CukeGlueAbstract;

/**
* Test Execution to append a fixture of SimpleObjects
*/
public class CatalogOfFixturesGlue extends CukeGlueAbstract {

@Before(value = {"@integration", "@SimpleObjectsFixture"}, order = 20000)
public void integrationFixtures() throws Throwable {
public void integrationFixtures() {
scenarioExecution().install(new RecreateSimpleObjects());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@

import cucumber.api.java.en.Given;
import cucumber.api.java.en.When;
import domainapp.dom.modules.simple.SimpleObject;
import domainapp.dom.modules.simple.SimpleObjects;
import java.util.List;
import java.util.UUID;
import org.apache.isis.core.specsupport.specs.CukeGlueAbstract;

Expand All @@ -40,9 +38,9 @@
public class SimpleObjectGlue extends CukeGlueAbstract {

@Given("^there are.* (\\d+) simple objects$")
public void thereAreNumSimpleObjects(int n) throws Throwable {
public void thereAreNumSimpleObjects(int n) {
try {
final List<SimpleObject> findAll = service(SimpleObjects.class).listAll();
final var findAll = service(SimpleObjects.class).listAll();
assertThat(findAll.size(), is(n));
putVar("list", "all", findAll);

Expand All @@ -52,7 +50,7 @@ public void thereAreNumSimpleObjects(int n) throws Throwable {
}

@When("^I create a new simple object$")
public void createNewSimpleObject() throws Throwable {
public void createNewSimpleObject() {
service(SimpleObjects.class).create(UUID.randomUUID().toString());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,17 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

import domainapp.dom.modules.simple.SimpleObject;
import domainapp.fixture.scenarios.RecreateSimpleObjects;
import domainapp.integtests.tests.SimpleAppIntegTest;
import javax.inject.Inject;

import org.apache.isis.applib.DomainObjectContainer;
import org.apache.isis.applib.fixturescripts.FixtureScripts;
import org.apache.isis.applib.services.wrapper.DisabledException;
import org.apache.isis.applib.services.wrapper.InvalidException;
import org.junit.Before;
import org.junit.Test;

import domainapp.dom.modules.simple.SimpleObject;
import domainapp.fixture.scenarios.RecreateSimpleObjects;
import domainapp.integtests.tests.SimpleAppIntegTest;

/**
* Test Fixtures with Simple Objects
*/
Expand All @@ -56,7 +54,7 @@ public class SimpleObjectIntegTest extends SimpleAppIntegTest {
private static final String NEW_NAME = "new name";

@Before
public void setUp() throws Exception {
public void setUp() {
// given
fs = new RecreateSimpleObjects().setNumber(1);
fixtureScripts.runFixtureScript(fs, null);
Expand All @@ -68,15 +66,15 @@ public void setUp() throws Exception {
}

@Test
public void testNameAccessible() throws Exception {
// when
final String name = simpleObjectWrapped.getName();
public void testNameAccessible() {
/* when */
final var name = simpleObjectWrapped.getName();
// then
assertEquals(fs.names.get(0), name);
}

@Test
public void testNameCannotBeUpdatedDirectly() throws Exception {
public void testNameCannotBeUpdatedDirectly() {

// expect
expectedExceptions.expect(DisabledException.class);
Expand All @@ -86,7 +84,7 @@ public void testNameCannotBeUpdatedDirectly() throws Exception {
}

@Test
public void testUpdateName() throws Exception {
public void testUpdateName() {

// when
simpleObjectWrapped.updateName(NEW_NAME);
Expand All @@ -96,7 +94,7 @@ public void testUpdateName() throws Exception {
}

@Test
public void testUpdateNameFailsValidation() throws Exception {
public void testUpdateNameFailsValidation() {

// expect
expectedExceptions.expect(InvalidException.class);
Expand All @@ -107,13 +105,13 @@ public void testUpdateNameFailsValidation() throws Exception {
}

@Test
public void testInterpolatesName() throws Exception {
public void testInterpolatesName() {

// given
final String name = simpleObjectWrapped.getName();
final var name = simpleObjectWrapped.getName();

// when
final String title = container.titleOf(simpleObjectWrapped);
final var title = container.titleOf(simpleObjectWrapped);

// then
assertEquals("Object: " + name, title);
Expand Down

0 comments on commit a5038c4

Please sign in to comment.