Skip to content

Commit 46c006c

Browse files
committed
Added Facade and Composite tests.
1 parent 1cbdf68 commit 46c006c

3 files changed

Lines changed: 36 additions & 9 deletions

File tree

‎Java/src/designpatterns/Facade.java‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,26 @@
44
* @author jtherrell
55
*/
66
class Facade {
7-
public void doSomething() {
8-
SubsystemClassA.doSomething();
9-
SubsystemClassB.doSomething();
10-
SubsystemClassC.doSomething();
11-
SubsystemClassD.doSomething();
7+
public void doSomething(Log log) {
8+
SubsystemClassA.doSomething(log);
9+
SubsystemClassB.doSomething(log);
10+
SubsystemClassC.doSomething(log);
11+
SubsystemClassD.doSomething(log);
1212
}
1313
}
1414

1515
class SubsystemClassA {
16-
public static void doSomething(){}
16+
public static void doSomething(Log log){log.append("A");}
1717
}
1818

1919
class SubsystemClassB {
20-
public static void doSomething(){}
20+
public static void doSomething(Log log){log.append("B");}
2121
}
2222

2323
class SubsystemClassC {
24-
public static void doSomething(){}
24+
public static void doSomething(Log log){log.append("C");}
2525
}
2626

2727
class SubsystemClassD {
28-
public static void doSomething(){}
28+
public static void doSomething(Log log){log.append("D");}
2929
}

‎Java/test/designpatterns/CompositeTest.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ public void testPictureGetChild() {
7171
* Test
7272
*/ @Test
7373
public void testPictureDraw() {
74+
Log log = new Log();
7475
Graphic compositeObj = new Picture();
7576
Graphic textObj = new Text();
7677
compositeObj.add(textObj);
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* To change this template, choose Tools | Templates
3+
* and open the template in the editor.
4+
*/
5+
6+
package designpatterns;
7+
8+
import org.junit.Test;
9+
import static org.junit.Assert.*;
10+
/**
11+
*
12+
* @author jtherrell
13+
*/
14+
public class FacadeTest {
15+
/**
16+
* Test of getInstance method, of class Singleton.
17+
*/ @Test
18+
public void testFacade() {
19+
Log log = new Log();
20+
Facade facade = new Facade();
21+
facade.doSomething(log);
22+
String expResult = "ABCD";
23+
String result = log.toString();
24+
assertEquals(expResult, result);
25+
}
26+
}

0 commit comments

Comments
 (0)