Skip to content

Commit 7874791

Browse files
committed
continuing work on test
1 parent 8925a9f commit 7874791

File tree

12 files changed

+20
-23
lines changed

12 files changed

+20
-23
lines changed

.classpath

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@
33
<classpathentry kind="src" path="src"/>
44
<classpathentry kind="src" path="test"/>
55
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
6-
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
7-
<classpathentry kind="con" path="org.springsource.ide.eclipse.gradle.classpathcontainer" exported="true"/>
6+
<classpathentry exported="true" kind="con" path="org.springsource.ide.eclipse.gradle.classpathcontainer"/>
7+
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
8+
<classpathentry exported="true" kind="lib" path="/Users/trish/.gradle/caches/modules-2/files-2.1/commons-collections/commons-collections/3.2/f951934aa5ae5a88d7e6dfaa6d32307d834a88be/commons-collections-3.2.jar" sourcepath="/Users/trish/.gradle/caches/modules-2/files-2.1/commons-collections/commons-collections/3.2/73d0340eaecbb0ec9d3e0ace90547ef08cbfaf27/commons-collections-3.2-sources.jar"/>
9+
<classpathentry exported="true" kind="lib" path="/Users/trish/.gradle/caches/modules-2/files-2.1/org.springframework/spring-core/4.0.4.RELEASE/1e49cd206349aa6d1ee272acd67cb56c05452b95/spring-core-4.0.4.RELEASE.jar" sourcepath="/Users/trish/.gradle/caches/modules-2/files-2.1/org.springframework/spring-core/4.0.4.RELEASE/c330409ccb1e521ffbadedfb3d4b79b67f38677f/spring-core-4.0.4.RELEASE-sources.jar"/>
10+
<classpathentry exported="true" kind="lib" path="/Users/trish/.gradle/caches/modules-2/files-2.1/org.mockito/mockito-all/1.9.5/79a8984096fc6591c1e3690e07d41be506356fa5/mockito-all-1.9.5.jar" sourcepath="/Users/trish/.gradle/caches/modules-2/files-2.1/org.mockito/mockito-all/1.9.5/b8086d4e4daa361fc746abea62f77a2ae55d3ed9/mockito-all-1.9.5-sources.jar"/>
11+
<classpathentry exported="true" kind="lib" path="/Users/trish/.gradle/caches/modules-2/files-2.1/junit/junit/4.11/4e031bb61df09069aeb2bffb4019e7a5034a4ee0/junit-4.11.jar" sourcepath="/Users/trish/.gradle/caches/modules-2/files-2.1/junit/junit/4.11/28e0ad201304e4a4abf999ca0570b7cffc352c3c/junit-4.11-sources.jar"/>
12+
<classpathentry exported="true" kind="lib" path="/Users/trish/.gradle/caches/modules-2/files-2.1/commons-logging/commons-logging/1.1.3/f6f66e966c70a83ffbdb6f17a0919eaf7c8aca7f/commons-logging-1.1.3.jar" sourcepath="/Users/trish/.gradle/caches/modules-2/files-2.1/commons-logging/commons-logging/1.1.3/28bb0405fddaf04f15058fbfbe01fe2780d7d3b6/commons-logging-1.1.3-sources.jar"/>
13+
<classpathentry exported="true" kind="lib" path="/Users/trish/.gradle/caches/modules-2/files-2.1/org.hamcrest/hamcrest-core/1.3/42a25dc3219429f0e5d060061f71acb49bf010a0/hamcrest-core-1.3.jar" sourcepath="/Users/trish/.gradle/caches/modules-2/files-2.1/org.hamcrest/hamcrest-core/1.3/1dc37250fbc78e23a65a67fbbaf71d2e9cbc3c0b/hamcrest-core-1.3-sources.jar"/>
814
<classpathentry kind="output" path="bin"/>
9-
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER" exported="true"/>
10-
<classpathentry sourcepath="/Users/trish/.gradle/caches/modules-2/files-2.1/commons-collections/commons-collections/3.2/73d0340eaecbb0ec9d3e0ace90547ef08cbfaf27/commons-collections-3.2-sources.jar" kind="lib" path="/Users/trish/.gradle/caches/modules-2/files-2.1/commons-collections/commons-collections/3.2/f951934aa5ae5a88d7e6dfaa6d32307d834a88be/commons-collections-3.2.jar" exported="true"/>
11-
<classpathentry sourcepath="/Users/trish/.gradle/caches/modules-2/files-2.1/org.springframework/spring-core/4.0.4.RELEASE/c330409ccb1e521ffbadedfb3d4b79b67f38677f/spring-core-4.0.4.RELEASE-sources.jar" kind="lib" path="/Users/trish/.gradle/caches/modules-2/files-2.1/org.springframework/spring-core/4.0.4.RELEASE/1e49cd206349aa6d1ee272acd67cb56c05452b95/spring-core-4.0.4.RELEASE.jar" exported="true"/>
12-
<classpathentry sourcepath="/Users/trish/.gradle/caches/modules-2/files-2.1/org.mockito/mockito-all/1.9.5/b8086d4e4daa361fc746abea62f77a2ae55d3ed9/mockito-all-1.9.5-sources.jar" kind="lib" path="/Users/trish/.gradle/caches/modules-2/files-2.1/org.mockito/mockito-all/1.9.5/79a8984096fc6591c1e3690e07d41be506356fa5/mockito-all-1.9.5.jar" exported="true"/>
13-
<classpathentry sourcepath="/Users/trish/.gradle/caches/modules-2/files-2.1/junit/junit/4.11/28e0ad201304e4a4abf999ca0570b7cffc352c3c/junit-4.11-sources.jar" kind="lib" path="/Users/trish/.gradle/caches/modules-2/files-2.1/junit/junit/4.11/4e031bb61df09069aeb2bffb4019e7a5034a4ee0/junit-4.11.jar" exported="true"/>
14-
<classpathentry sourcepath="/Users/trish/.gradle/caches/modules-2/files-2.1/commons-logging/commons-logging/1.1.3/28bb0405fddaf04f15058fbfbe01fe2780d7d3b6/commons-logging-1.1.3-sources.jar" kind="lib" path="/Users/trish/.gradle/caches/modules-2/files-2.1/commons-logging/commons-logging/1.1.3/f6f66e966c70a83ffbdb6f17a0919eaf7c8aca7f/commons-logging-1.1.3.jar" exported="true"/>
15-
<classpathentry sourcepath="/Users/trish/.gradle/caches/modules-2/files-2.1/org.hamcrest/hamcrest-core/1.3/1dc37250fbc78e23a65a67fbbaf71d2e9cbc3c0b/hamcrest-core-1.3-sources.jar" kind="lib" path="/Users/trish/.gradle/caches/modules-2/files-2.1/org.hamcrest/hamcrest-core/1.3/42a25dc3219429f0e5d060061f71acb49bf010a0/hamcrest-core-1.3.jar" exported="true"/>
1615
</classpath>

bin/halterman/command/Client.class

927 Bytes
Binary file not shown.

bin/halterman/command/Command.class

137 Bytes
Binary file not shown.
1.1 KB
Binary file not shown.

bin/halterman/command/Light.class

658 Bytes
Binary file not shown.
576 Bytes
Binary file not shown.
572 Bytes
Binary file not shown.

bin/halterman/command/Switch.class

594 Bytes
Binary file not shown.

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ repositories {
1616
dependencies {
1717
compile group: 'commons-collections', name: 'commons-collections', version: '3.2'
1818
compile 'org.springframework:spring-core:4.0.4.RELEASE'
19-
compile group: 'org.mockito', name: 'mockito-all', version:'1.9.5'
19+
testCompile group: 'org.mockito', name: 'mockito-all', version:'1.9.5'
2020
testCompile group: 'junit', name: 'junit', version: '4.+'
2121
}
2222

build/libs/designpatterns-1.0.jar

0 Bytes
Binary file not shown.

src/halterman/command/Client.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public static void main(String[] args) {
77
//Invoker
88
Switch lightSwitch = new Switch();
99

10-
//Receiver
10+
//Light
1111
Light light = new Light();
1212

1313
//Concrete Commands from Command Interface

test/halterman/command/CommandPatternTest.java

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,40 +6,38 @@
66
import halterman.command.LightOnCommand;
77
import halterman.command.Switch;
88

9+
import org.mockito.InjectMocks;
910
import org.mockito.Mock;
1011
import org.mockito.Mockito;
1112
import org.mockito.MockitoAnnotations;
13+
import static org.mockito.Mockito.verify;
1214

1315
import org.junit.Before;
1416
import org.junit.Test;
1517

1618
public class CommandPatternTest {
1719

20+
@InjectMocks
21+
private Switch lightSwitch;
22+
1823
@Mock
1924
Light light;
2025

2126
@Mock
2227
Command lightsOn;
2328

24-
private Switch control;
25-
26-
@Before
29+
@Before
2730
public void setUp() {
2831
MockitoAnnotations.initMocks(this);
29-
control = new Switch();
32+
lightSwitch = new Switch();
3033
}
3134

3235
@Test
3336
public void shouldTurnOnLight() {
34-
Command lightsOn = new LightOnCommand(light);
35-
36-
// switch on
37-
control.setCommand(lightsOn);
38-
control.pressButton();
39-
40-
//verify
37+
lightSwitch.pressButton();
38+
4139

42-
// Need Mockito here, will work on this from home.
40+
verify(light).switchOn();
4341
}
4442

4543

0 commit comments

Comments
 (0)