Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
QZero_0
java-design-patterns
提交
d0ed10a6
J
java-design-patterns
项目概览
QZero_0
/
java-design-patterns
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
java-design-patterns
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
d0ed10a6
编写于
8月 08, 2020
作者:
I
Ilkka Seppälä
提交者:
GitHub
8月 08, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1479 from anuragagarwal561994/java-11
Java 11 remaining pattern
上级
b0ac4c1c
134ccdb5
变更
22
隐藏空白更改
内联
并排
Showing
22 changed file
with
124 addition
and
168 deletion
+124
-168
naked-objects/dom/pom.xml
naked-objects/dom/pom.xml
+1
-1
naked-objects/dom/src/main/java/domainapp/dom/app/homepage/HomePageViewModel.layout.json
.../domainapp/dom/app/homepage/HomePageViewModel.layout.json
+0
-16
naked-objects/dom/src/main/java/domainapp/dom/modules/simple/SimpleObject.java
.../main/java/domainapp/dom/modules/simple/SimpleObject.java
+2
-2
naked-objects/dom/src/main/java/domainapp/dom/modules/simple/SimpleObject.layout.json
...ava/domainapp/dom/modules/simple/SimpleObject.layout.json
+0
-16
naked-objects/dom/src/test/java/domainapp/dom/modules/simple/SimpleObjectTest.java
...t/java/domainapp/dom/modules/simple/SimpleObjectTest.java
+2
-2
naked-objects/dom/src/test/java/domainapp/dom/modules/simple/SimpleObjectsTest.java
.../java/domainapp/dom/modules/simple/SimpleObjectsTest.java
+3
-3
naked-objects/fixture/src/main/java/domainapp/fixture/modules/simple/SimpleObjectCreate.java
.../domainapp/fixture/modules/simple/SimpleObjectCreate.java
+1
-2
naked-objects/fixture/src/main/java/domainapp/fixture/scenarios/RecreateSimpleObjects.java
...va/domainapp/fixture/scenarios/RecreateSimpleObjects.java
+15
-6
naked-objects/integtests/src/test/java/domainapp/integtests/bootstrap/SimpleAppSystemInitializer.java
...napp/integtests/bootstrap/SimpleAppSystemInitializer.java
+2
-3
naked-objects/integtests/src/test/java/domainapp/integtests/specglue/CatalogOfFixturesGlue.java
.../domainapp/integtests/specglue/CatalogOfFixturesGlue.java
+2
-3
naked-objects/integtests/src/test/java/domainapp/integtests/specglue/modules/simple/SimpleObjectGlue.java
.../integtests/specglue/modules/simple/SimpleObjectGlue.java
+3
-5
naked-objects/integtests/src/test/java/domainapp/integtests/tests/modules/simple/SimpleObjectIntegTest.java
...ntegtests/tests/modules/simple/SimpleObjectIntegTest.java
+13
-15
naked-objects/integtests/src/test/java/domainapp/integtests/tests/modules/simple/SimpleObjectsIntegTest.java
...tegtests/tests/modules/simple/SimpleObjectsIntegTest.java
+25
-33
naked-objects/webapp/ide/eclipse/launch/.gitignore
naked-objects/webapp/ide/eclipse/launch/.gitignore
+0
-4
naked-objects/webapp/pom.xml
naked-objects/webapp/pom.xml
+1
-1
naked-objects/webapp/src/main/java/domainapp/webapp/SimpleApplication.java
...app/src/main/java/domainapp/webapp/SimpleApplication.java
+10
-16
naked-objects/webapp/src/main/webapp/about/index.html
naked-objects/webapp/src/main/webapp/about/index.html
+2
-2
null-object/README.md
null-object/README.md
+10
-5
null-object/src/main/java/com/iluwatar/nullobject/App.java
null-object/src/main/java/com/iluwatar/nullobject/App.java
+10
-6
null-object/src/test/java/com/iluwatar/nullobject/AppTest.java
...object/src/test/java/com/iluwatar/nullobject/AppTest.java
+1
-5
null-object/src/test/java/com/iluwatar/nullobject/NullNodeTest.java
...t/src/test/java/com/iluwatar/nullobject/NullNodeTest.java
+2
-2
null-object/src/test/java/com/iluwatar/nullobject/TreeTest.java
...bject/src/test/java/com/iluwatar/nullobject/TreeTest.java
+19
-20
未找到文件。
naked-objects/dom/pom.xml
浏览文件 @
d0ed10a6
...
...
@@ -127,7 +127,7 @@
</goals>
</pluginExecutionFilter>
<action>
<ignore
></ignore
>
<ignore
/
>
</action>
</pluginExecution>
</pluginExecutions>
...
...
naked-objects/dom/src/main/java/domainapp/dom/app/homepage/HomePageViewModel.layout.json
浏览文件 @
d0ed10a6
/**
*
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"
:
[
{
...
...
naked-objects/dom/src/main/java/domainapp/dom/modules/simple/SimpleObject.java
浏览文件 @
d0ed10a6
...
...
@@ -50,9 +50,9 @@ import org.apache.isis.applib.util.ObjectContracts;
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
...
...
naked-objects/dom/src/main/java/domainapp/dom/modules/simple/SimpleObject.layout.json
浏览文件 @
d0ed10a6
/**
*
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"
:
[
{
...
...
naked-objects/dom/src/test/java/domainapp/dom/modules/simple/SimpleObjectTest.java
浏览文件 @
d0ed10a6
...
...
@@ -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
());
...
...
naked-objects/dom/src/test/java/domainapp/dom/modules/simple/SimpleObjectsTest.java
浏览文件 @
d0ed10a6
...
...
@@ -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
();
...
...
@@ -85,7 +85,7 @@ public class SimpleObjectsTest {
}
@Test
public
void
testListAll
()
throws
Exception
{
public
void
testListAll
()
{
// given
final
List
<
SimpleObject
>
all
=
Lists
.
newArrayList
();
...
...
naked-objects/fixture/src/main/java/domainapp/fixture/modules/simple/SimpleObjectCreate.java
浏览文件 @
d0ed10a6
...
...
@@ -67,8 +67,7 @@ public class SimpleObjectCreate extends FixtureScript {
@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
);
...
...
naked-objects/fixture/src/main/java/domainapp/fixture/scenarios/RecreateSimpleObjects.java
浏览文件 @
d0ed10a6
...
...
@@ -27,7 +27,6 @@ import com.google.common.collect.Lists;
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
;
...
...
@@ -37,8 +36,18 @@ import org.apache.isis.applib.fixturescripts.FixtureScript;
*/
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
;
...
...
@@ -77,7 +86,7 @@ public class RecreateSimpleObjects extends FixtureScript {
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
())
{
...
...
@@ -90,8 +99,8 @@ public class RecreateSimpleObjects extends FixtureScript {
//
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
());
}
...
...
naked-objects/integtests/src/test/java/domainapp/integtests/bootstrap/SimpleAppSystemInitializer.java
浏览文件 @
d0ed10a6
...
...
@@ -40,7 +40,7 @@ public final class 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
);
...
...
@@ -58,8 +58,7 @@ public final class SimpleAppSystemInitializer {
}
private
static
IsisConfiguration
testConfiguration
()
{
final
IsisConfigurationForJdoIntegTests
testConfiguration
=
new
IsisConfigurationForJdoIntegTests
();
final
var
testConfiguration
=
new
IsisConfigurationForJdoIntegTests
();
testConfiguration
.
addRegisterEntitiesPackagePrefix
(
"domainapp.dom.modules"
);
return
testConfiguration
;
...
...
naked-objects/integtests/src/test/java/domainapp/integtests/specglue/CatalogOfFixturesGlue.java
浏览文件 @
d0ed10a6
...
...
@@ -23,10 +23,9 @@
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
...
...
@@ -34,7 +33,7 @@ import domainapp.fixture.scenarios.RecreateSimpleObjects;
public
class
CatalogOfFixturesGlue
extends
CukeGlueAbstract
{
@Before
(
value
=
{
"@integration"
,
"@SimpleObjectsFixture"
},
order
=
20000
)
public
void
integrationFixtures
()
throws
Throwable
{
public
void
integrationFixtures
()
{
scenarioExecution
().
install
(
new
RecreateSimpleObjects
());
}
}
naked-objects/integtests/src/test/java/domainapp/integtests/specglue/modules/simple/SimpleObjectGlue.java
浏览文件 @
d0ed10a6
...
...
@@ -28,9 +28,7 @@ import static org.junit.Assert.assertThat;
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
;
...
...
@@ -40,9 +38,9 @@ import org.apache.isis.core.specsupport.specs.CukeGlueAbstract;
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
);
...
...
@@ -52,7 +50,7 @@ public class SimpleObjectGlue extends CukeGlueAbstract {
}
@When
(
"^I create a new simple object$"
)
public
void
createNewSimpleObject
()
throws
Throwable
{
public
void
createNewSimpleObject
()
{
service
(
SimpleObjects
.
class
).
create
(
UUID
.
randomUUID
().
toString
());
}
...
...
naked-objects/integtests/src/test/java/domainapp/integtests/tests/modules/simple/SimpleObjectIntegTest.java
浏览文件 @
d0ed10a6
...
...
@@ -26,8 +26,10 @@ package domainapp.integtests.tests.modules.simple;
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
;
...
...
@@ -35,10 +37,6 @@ 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
*/
...
...
@@ -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
);
...
...
@@ -68,15 +66,15 @@ public class SimpleObjectIntegTest extends SimpleAppIntegTest {
}
@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
);
...
...
@@ -86,7 +84,7 @@ public class SimpleObjectIntegTest extends SimpleAppIntegTest {
}
@Test
public
void
testUpdateName
()
throws
Exception
{
public
void
testUpdateName
()
{
// when
simpleObjectWrapped
.
updateName
(
NEW_NAME
);
...
...
@@ -96,7 +94,7 @@ public class SimpleObjectIntegTest extends SimpleAppIntegTest {
}
@Test
public
void
testUpdateNameFailsValidation
()
throws
Exception
{
public
void
testUpdateNameFailsValidation
()
{
// expect
expectedExceptions
.
expect
(
InvalidException
.
class
);
...
...
@@ -107,13 +105,13 @@ public class SimpleObjectIntegTest extends SimpleAppIntegTest {
}
@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
);
...
...
naked-objects/integtests/src/test/java/domainapp/integtests/tests/modules/simple/SimpleObjectsIntegTest.java
浏览文件 @
d0ed10a6
...
...
@@ -25,11 +25,13 @@ package domainapp.integtests.tests.modules.simple;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
com.google.common.base.Throwables
;
import
domainapp.dom.modules.simple.SimpleObjects
;
import
domainapp.fixture.modules.simple.SimpleObjectsTearDown
;
import
domainapp.fixture.scenarios.RecreateSimpleObjects
;
import
domainapp.integtests.tests.SimpleAppIntegTest
;
import
java.sql.SQLIntegrityConstraintViolationException
;
import
java.util.List
;
import
javax.inject.Inject
;
import
org.apache.isis.applib.fixturescripts.FixtureScript
;
import
org.apache.isis.applib.fixturescripts.FixtureScripts
;
import
org.hamcrest.Description
;
...
...
@@ -37,14 +39,6 @@ import org.hamcrest.Matcher;
import
org.hamcrest.TypeSafeMatcher
;
import
org.junit.Test
;
import
com.google.common.base.Throwables
;
import
domainapp.dom.modules.simple.SimpleObject
;
import
domainapp.dom.modules.simple.SimpleObjects
;
import
domainapp.fixture.modules.simple.SimpleObjectsTearDown
;
import
domainapp.fixture.scenarios.RecreateSimpleObjects
;
import
domainapp.integtests.tests.SimpleAppIntegTest
;
/**
* Fixture Pattern Integration Test
*/
...
...
@@ -56,25 +50,25 @@ public class SimpleObjectsIntegTest extends SimpleAppIntegTest {
SimpleObjects
simpleObjects
;
@Test
public
void
testListAll
()
throws
Exception
{
public
void
testListAll
()
{
// given
RecreateSimpleObjects
fs
=
new
RecreateSimpleObjects
();
var
fs
=
new
RecreateSimpleObjects
();
fixtureScripts
.
runFixtureScript
(
fs
,
null
);
nextTransaction
();
// when
final
List
<
SimpleObject
>
all
=
wrap
(
simpleObjects
).
listAll
();
final
var
all
=
wrap
(
simpleObjects
).
listAll
();
// then
assertEquals
(
fs
.
getSimpleObjects
().
size
(),
all
.
size
());
SimpleObject
simpleObject
=
wrap
(
all
.
get
(
0
));
var
simpleObject
=
wrap
(
all
.
get
(
0
));
assertEquals
(
fs
.
getSimpleObjects
().
get
(
0
).
getName
(),
simpleObject
.
getName
());
}
@Test
public
void
testListAllWhenNone
()
throws
Exception
{
public
void
testListAllWhenNone
()
{
// given
FixtureScript
fs
=
new
SimpleObjectsTearDown
();
...
...
@@ -82,14 +76,14 @@ public class SimpleObjectsIntegTest extends SimpleAppIntegTest {
nextTransaction
();
// when
final
List
<
SimpleObject
>
all
=
wrap
(
simpleObjects
).
listAll
();
final
var
all
=
wrap
(
simpleObjects
).
listAll
();
// then
assertEquals
(
0
,
all
.
size
());
}
@Test
public
void
testCreate
()
throws
Exception
{
public
void
testCreate
()
{
// given
FixtureScript
fs
=
new
SimpleObjectsTearDown
();
...
...
@@ -100,12 +94,12 @@ public class SimpleObjectsIntegTest extends SimpleAppIntegTest {
wrap
(
simpleObjects
).
create
(
"Faz"
);
// then
final
List
<
SimpleObject
>
all
=
wrap
(
simpleObjects
).
listAll
();
final
var
all
=
wrap
(
simpleObjects
).
listAll
();
assertEquals
(
1
,
all
.
size
());
}
@Test
public
void
testCreateWhenAlreadyExists
()
throws
Exception
{
public
void
testCreateWhenAlreadyExists
()
{
// given
FixtureScript
fs
=
new
SimpleObjectsTearDown
();
...
...
@@ -115,24 +109,22 @@ public class SimpleObjectsIntegTest extends SimpleAppIntegTest {
nextTransaction
();
// then
expectedExceptions
.
expectCause
(
causalChainContains
(
SQLIntegrityConstraintViolationException
.
class
));
expectedExceptions
.
expectCause
(
causalChainContains
(
SQLIntegrityConstraintViolationException
.
class
));
// when
wrap
(
simpleObjects
).
create
(
"Faz"
);
nextTransaction
();
}
@SuppressWarnings
(
"SameParameterValue"
)
private
static
Matcher
<?
extends
Throwable
>
causalChainContains
(
final
Class
<?>
cls
)
{
return
new
TypeSafeMatcher
<
Throwable
>()
{
return
new
TypeSafeMatcher
<>()
{
@Override
@SuppressWarnings
(
"UnstableApiUsage"
)
protected
boolean
matchesSafely
(
Throwable
item
)
{
final
List
<
Throwable
>
causalChain
=
Throwables
.
getCausalChain
(
item
);
for
(
Throwable
throwable
:
causalChain
)
{
if
(
cls
.
isAssignableFrom
(
throwable
.
getClass
()))
{
return
true
;
}
}
return
false
;
final
var
causalChain
=
Throwables
.
getCausalChain
(
item
);
return
causalChain
.
stream
().
map
(
Throwable:
:
getClass
).
anyMatch
(
cls:
:
isAssignableFrom
);
}
@Override
...
...
naked-objects/webapp/ide/eclipse/launch/.gitignore
浏览文件 @
d0ed10a6
...
...
@@ -2,7 +2,3 @@
/SimpleApp-PROTOTYPE-no-fixtures.launch
/SimpleApp-PROTOTYPE-with-fixtures.launch
/SimpleApp-SERVER-no-fixtures.launch
/SimpleApp-PROTOTYPE-jrebel.launch
/SimpleApp-PROTOTYPE-no-fixtures.launch
/SimpleApp-PROTOTYPE-with-fixtures.launch
/SimpleApp-SERVER-no-fixtures.launch
naked-objects/webapp/pom.xml
浏览文件 @
d0ed10a6
...
...
@@ -129,7 +129,7 @@
</goals>
</pluginExecutionFilter>
<action>
<ignore
></ignore
>
<ignore
/
>
</action>
</pluginExecution>
</pluginExecutions>
...
...
naked-objects/webapp/src/main/java/domainapp/webapp/SimpleApplication.java
浏览文件 @
d0ed10a6
...
...
@@ -31,18 +31,15 @@ import com.google.inject.name.Names;
import
com.google.inject.util.Modules
;
import
com.google.inject.util.Providers
;
import
de.agilecoders.wicket.core.Bootstrap
;
import
de.agilecoders.wicket.core.settings.IBootstrapSettings
;
import
de.agilecoders.wicket.themes.markup.html.bootswatch.BootswatchTheme
;
import
de.agilecoders.wicket.themes.markup.html.bootswatch.BootswatchThemeProvider
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.nio.charset.Charset
;
import
java.util.List
;
import
javax.servlet.http.HttpServletRequest
;
import
org.apache.isis.viewer.wicket.viewer.IsisWicketApplication
;
import
org.apache.isis.viewer.wicket.viewer.integration.wicket.AuthenticatedWebSessionForIsis
;
import
org.apache.wicket.Session
;
import
org.apache.wicket.request.IRequestParameters
;
import
org.apache.wicket.request.Request
;
import
org.apache.wicket.request.Response
;
import
org.apache.wicket.request.http.WebRequest
;
...
...
@@ -85,7 +82,7 @@ public class SimpleApplication extends IsisWicketApplication {
protected
void
init
()
{
super
.
init
();
IBootstrapSettings
settings
=
Bootstrap
.
getSettings
();
var
settings
=
Bootstrap
.
getSettings
();
settings
.
setThemeProvider
(
new
BootswatchThemeProvider
(
BootswatchTheme
.
Flatly
));
}
...
...
@@ -96,13 +93,10 @@ public class SimpleApplication extends IsisWicketApplication {
}
// else demo mode
final
AuthenticatedWebSessionForIsis
s
=
(
AuthenticatedWebSessionForIsis
)
super
.
newSession
(
request
,
response
);
IRequestParameters
requestParameters
=
request
.
getRequestParameters
();
final
org
.
apache
.
wicket
.
util
.
string
.
StringValue
user
=
requestParameters
.
getParameterValue
(
"user"
);
final
org
.
apache
.
wicket
.
util
.
string
.
StringValue
password
=
requestParameters
.
getParameterValue
(
"pass"
);
final
var
s
=
(
AuthenticatedWebSessionForIsis
)
super
.
newSession
(
request
,
response
);
var
requestParameters
=
request
.
getRequestParameters
();
final
var
user
=
requestParameters
.
getParameterValue
(
"user"
);
final
var
password
=
requestParameters
.
getParameterValue
(
"pass"
);
s
.
signIn
(
user
.
toString
(),
password
.
toString
());
return
s
;
}
...
...
@@ -115,7 +109,7 @@ public class SimpleApplication extends IsisWicketApplication {
// else demo mode
try
{
String
uname
=
servletRequest
.
getParameter
(
"user"
);
var
uname
=
servletRequest
.
getParameter
(
"user"
);
if
(
uname
!=
null
)
{
servletRequest
.
getSession
().
invalidate
();
}
...
...
@@ -127,7 +121,7 @@ public class SimpleApplication extends IsisWicketApplication {
@Override
protected
Module
newIsisWicketModule
()
{
final
Module
isisDefaults
=
super
.
newIsisWicketModule
();
final
var
isisDefaults
=
super
.
newIsisWicketModule
();
final
Module
overrides
=
new
AbstractModule
()
{
@Override
...
...
@@ -148,11 +142,11 @@ public class SimpleApplication extends IsisWicketApplication {
return
Modules
.
override
(
isisDefaults
).
with
(
overrides
);
}
@SuppressWarnings
({
"UnstableApiUsage"
,
"SameParameterValue"
})
private
static
String
readLines
(
final
Class
<?>
contextClass
,
final
String
resourceName
)
{
try
{
List
<
String
>
readLines
=
Resources
.
readLines
(
Resources
.
getResource
(
contextClass
,
resourceName
),
Charset
.
defaultCharset
());
var
resource
=
Resources
.
getResource
(
contextClass
,
resourceName
);
var
readLines
=
Resources
.
readLines
(
resource
,
Charset
.
defaultCharset
());
return
Joiner
.
on
(
"\n"
).
join
(
readLines
);
}
catch
(
IOException
e
)
{
return
"This is a simple app"
;
...
...
naked-objects/webapp/src/main/webapp/about/index.html
浏览文件 @
d0ed10a6
...
...
@@ -110,8 +110,8 @@ th, td {
</p>
<p>
provides access to a RESTful API conformant with the
<a
href=
"http://restfulobjects.org"
>
Restful Objects
</a>
spec
</td>
. This is part of Apache Isis Core. The
implementation technology is JBoss RestEasy.
<a
href=
"http://restfulobjects.org"
>
Restful Objects
</a>
spec
. This is part of Apache Isis Core.
The
implementation technology is JBoss RestEasy.
</p>
</li>
</ul>
...
...
null-object/README.md
浏览文件 @
d0ed10a6
...
...
@@ -141,11 +141,16 @@ public final class NullNode implements Node {
Then we can construct and traverse the binary tree without errors as follows.
```
java
Node
root
=
new
NodeImpl
(
"1"
,
new
NodeImpl
(
"11"
,
new
NodeImpl
(
"111"
,
NullNode
.
getInstance
(),
NullNode
.
getInstance
()),
NullNode
.
getInstance
()),
new
NodeImpl
(
"12"
,
NullNode
.
getInstance
(),
new
NodeImpl
(
"122"
,
NullNode
.
getInstance
(),
NullNode
.
getInstance
())));
var
root
=
new
NodeImpl
(
"1"
,
new
NodeImpl
(
"11"
,
new
NodeImpl
(
"111"
,
NullNode
.
getInstance
(),
NullNode
.
getInstance
()),
NullNode
.
getInstance
()
),
new
NodeImpl
(
"12"
,
NullNode
.
getInstance
(),
new
NodeImpl
(
"122"
,
NullNode
.
getInstance
(),
NullNode
.
getInstance
())
)
);
root
.
walk
();
// 1
...
...
null-object/src/main/java/com/iluwatar/nullobject/App.java
浏览文件 @
d0ed10a6
...
...
@@ -37,12 +37,16 @@ public class App {
* @param args command line args
*/
public
static
void
main
(
String
[]
args
)
{
Node
root
=
new
NodeImpl
(
"1"
,
new
NodeImpl
(
"11"
,
new
NodeImpl
(
"111"
,
NullNode
.
getInstance
(),
NullNode
.
getInstance
()),
NullNode
.
getInstance
()),
new
NodeImpl
(
"12"
,
NullNode
.
getInstance
(),
new
NodeImpl
(
"122"
,
NullNode
.
getInstance
(),
NullNode
.
getInstance
())));
var
root
=
new
NodeImpl
(
"1"
,
new
NodeImpl
(
"11"
,
new
NodeImpl
(
"111"
,
NullNode
.
getInstance
(),
NullNode
.
getInstance
()),
NullNode
.
getInstance
()
),
new
NodeImpl
(
"12"
,
NullNode
.
getInstance
(),
new
NodeImpl
(
"122"
,
NullNode
.
getInstance
(),
NullNode
.
getInstance
())
)
);
root
.
walk
();
}
...
...
null-object/src/test/java/com/iluwatar/nullobject/AppTest.java
浏览文件 @
d0ed10a6
...
...
@@ -26,15 +26,11 @@ package com.iluwatar.nullobject;
import
org.junit.jupiter.api.Test
;
/**
*
* Application test
*
*/
public
class
AppTest
{
@Test
public
void
test
()
{
String
[]
args
=
{};
App
.
main
(
args
);
App
.
main
(
new
String
[]{});
}
}
null-object/src/test/java/com/iluwatar/nullobject/NullNodeTest.java
浏览文件 @
d0ed10a6
...
...
@@ -42,14 +42,14 @@ public class NullNodeTest {
*/
@Test
public
void
testGetInstance
()
{
final
NullNode
instance
=
NullNode
.
getInstance
();
final
var
instance
=
NullNode
.
getInstance
();
assertNotNull
(
instance
);
assertSame
(
instance
,
NullNode
.
getInstance
());
}
@Test
public
void
testFields
()
{
final
NullNode
node
=
NullNode
.
getInstance
();
final
var
node
=
NullNode
.
getInstance
();
assertEquals
(
0
,
node
.
getTreeSize
());
assertNull
(
node
.
getName
());
assertNull
(
node
.
getLeft
());
...
...
null-object/src/test/java/com/iluwatar/nullobject/TreeTest.java
浏览文件 @
d0ed10a6
...
...
@@ -23,22 +23,21 @@
package
com.iluwatar.nullobject
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertEquals
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertNotNull
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertSame
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertTrue
;
import
ch.qos.logback.classic.Logger
;
import
ch.qos.logback.classic.spi.ILoggingEvent
;
import
ch.qos.logback.core.AppenderBase
;
import
java.util.LinkedList
;
import
java.util.List
;
import
org.junit.jupiter.api.AfterEach
;
import
org.junit.jupiter.api.BeforeEach
;
import
org.junit.jupiter.api.Test
;
import
org.slf4j.LoggerFactory
;
import
java.util.LinkedList
;
import
java.util.List
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertEquals
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertNotNull
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertSame
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertTrue
;
/**
* Date: 12/26/15 - 11:44 PM
*
...
...
@@ -75,12 +74,12 @@ public class TreeTest {
private
static
final
Node
TREE_ROOT
;
static
{
final
NodeImpl
level1B
=
new
NodeImpl
(
"level1_b"
,
NullNode
.
getInstance
(),
NullNode
.
getInstance
());
final
NodeImpl
level2B
=
new
NodeImpl
(
"level2_b"
,
NullNode
.
getInstance
(),
NullNode
.
getInstance
());
final
NodeImpl
level3A
=
new
NodeImpl
(
"level3_a"
,
NullNode
.
getInstance
(),
NullNode
.
getInstance
());
final
NodeImpl
level3B
=
new
NodeImpl
(
"level3_b"
,
NullNode
.
getInstance
(),
NullNode
.
getInstance
());
final
NodeImpl
level2A
=
new
NodeImpl
(
"level2_a"
,
level3A
,
level3B
);
final
NodeImpl
level1A
=
new
NodeImpl
(
"level1_a"
,
level2A
,
level2B
);
final
var
level1B
=
new
NodeImpl
(
"level1_b"
,
NullNode
.
getInstance
(),
NullNode
.
getInstance
());
final
var
level2B
=
new
NodeImpl
(
"level2_b"
,
NullNode
.
getInstance
(),
NullNode
.
getInstance
());
final
var
level3A
=
new
NodeImpl
(
"level3_a"
,
NullNode
.
getInstance
(),
NullNode
.
getInstance
());
final
var
level3B
=
new
NodeImpl
(
"level3_b"
,
NullNode
.
getInstance
(),
NullNode
.
getInstance
());
final
var
level2A
=
new
NodeImpl
(
"level2_a"
,
level3A
,
level3B
);
final
var
level1A
=
new
NodeImpl
(
"level1_a"
,
level2A
,
level2B
);
TREE_ROOT
=
new
NodeImpl
(
"root"
,
level1A
,
level1B
);
}
...
...
@@ -112,17 +111,17 @@ public class TreeTest {
@Test
public
void
testGetLeft
()
{
final
Node
level1
=
TREE_ROOT
.
getLeft
();
final
var
level1
=
TREE_ROOT
.
getLeft
();
assertNotNull
(
level1
);
assertEquals
(
"level1_a"
,
level1
.
getName
());
assertEquals
(
5
,
level1
.
getTreeSize
());
final
Node
level2
=
level1
.
getLeft
();
final
var
level2
=
level1
.
getLeft
();
assertNotNull
(
level2
);
assertEquals
(
"level2_a"
,
level2
.
getName
());
assertEquals
(
3
,
level2
.
getTreeSize
());
final
Node
level3
=
level2
.
getLeft
();
final
var
level3
=
level2
.
getLeft
();
assertNotNull
(
level3
);
assertEquals
(
"level3_a"
,
level3
.
getName
());
assertEquals
(
1
,
level3
.
getTreeSize
());
...
...
@@ -132,7 +131,7 @@ public class TreeTest {
@Test
public
void
testGetRight
()
{
final
Node
level1
=
TREE_ROOT
.
getRight
();
final
var
level1
=
TREE_ROOT
.
getRight
();
assertNotNull
(
level1
);
assertEquals
(
"level1_b"
,
level1
.
getName
());
assertEquals
(
1
,
level1
.
getTreeSize
());
...
...
@@ -140,7 +139,7 @@ public class TreeTest {
assertSame
(
NullNode
.
getInstance
(),
level1
.
getLeft
());
}
private
class
InMemoryAppender
extends
AppenderBase
<
ILoggingEvent
>
{
private
static
class
InMemoryAppender
extends
AppenderBase
<
ILoggingEvent
>
{
private
final
List
<
ILoggingEvent
>
log
=
new
LinkedList
<>();
public
InMemoryAppender
()
{
...
...
@@ -154,7 +153,7 @@ public class TreeTest {
}
public
boolean
logContains
(
String
message
)
{
return
log
.
stream
().
anyMatch
(
event
->
event
.
getMessage
().
equals
(
message
)
);
return
log
.
stream
().
map
(
ILoggingEvent:
:
getMessage
).
anyMatch
(
message:
:
equals
);
}
public
int
getLogSize
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录