1- package com .baeldung .doublecolumn ;
1+ package com .baeldung .doublecolon ;
22
3- import com .baeldung .doublecolumn .function .TriFunction ;
3+ import com .baeldung .doublecolon .function .TriFunction ;
44import org .junit .After ;
55import org .junit .Assert ;
66import org .junit .Before ;
99import java .util .*;
1010import java .util .function .BiFunction ;
1111
12- import static com .baeldung .doublecolumn .ComputerUtils .*;
12+ import static com .baeldung .doublecolon .ComputerUtils .*;
1313
1414public class TestComputerUtils {
1515
@@ -22,7 +22,7 @@ public void tearDown() {
2222 }
2323
2424 @ Test
25- public void testFilter () {
25+ public void testConstructorReference () {
2626
2727 Computer c1 = new Computer (2015 , "white" );
2828 Computer c2 = new Computer (2009 , "black" );
@@ -53,7 +53,7 @@ public void testFilter() {
5353 }
5454
5555 @ Test
56- public void testRepair () {
56+ public void testStaticMethodReference () {
5757
5858 Computer c1 = new Computer (2015 , "white" , 35 );
5959 Computer c2 = new Computer (2009 , "black" , 65 );
@@ -66,4 +66,24 @@ public void testRepair() {
6666 Assert .assertEquals ("Computer repaired" , new Integer (100 ), c1 .getHealty ());
6767 }
6868
69+ @ Test
70+ public void testInstanceMethodArbitraryObjectParticularType () {
71+
72+ Computer c1 = new Computer (2015 , "white" , 35 );
73+ Computer c2 = new MacbookPro (2009 , "black" , 65 );
74+ List <Computer > inventory = Arrays .asList (c1 , c2 );
75+ inventory .forEach (Computer ::turnOnPc );
76+
77+ }
78+
79+ @ Test
80+ public void testSuperMethodReference () {
81+
82+ final TriFunction <Integer , String , Integer , MacbookPro > integerStringIntegerObjectTriFunction = MacbookPro ::new ;
83+ final MacbookPro macbookPro = integerStringIntegerObjectTriFunction .apply (2010 , "black" ,100 );
84+ Double initialValue =new Double (999.99 );
85+ final Double actualValue = macbookPro .calculateValue (initialValue );
86+ Assert .assertEquals (766.659 , actualValue ,0.0 );
87+ }
88+
6989}
0 commit comments