package es.sandbox.spikes.java8.interfaces;

import es.sandbox.spikes.java8.InvocationSpy;
import org.junit.Before;
import org.junit.Test;

import static es.sandbox.spikes.java8.FunctionalInterfaceCaller.call;
import static es.sandbox.spikes.java8.InvocationSpy.spy;
import static org.assertj.core.api.Assertions.assertThat;

/**
 * Created by jeslopalo on 30/12/15.
 */
public class FunctionalInterfaceSpecs {

    private InvocationSpy spy;

    @Before
    public void setup() {
        this.spy = spy();
    }

    @Test
    public void has_one_callable_method() {
        call(() -> this.spy.invocation());

        assertThat(this.spy.invoked()).isTrue();
    }
}

package es.sandbox.spikes.java8.interfaces;

import es.sandbox.spikes.java8.InvocationSpy;
import org.junit.Before;
import org.junit.Test;

import static es.sandbox.spikes.java8.InvocationSpy.spy;
import static org.assertj.core.api.Assertions.assertThat;

/**
 * Created by jeslopalo on 30/12/15.
 */
public class FunctionalInterfaceSpecs {

    private InvocationSpy spy;

    private static final void callFunctionalInterface(SimpleFunctionalInterface functionalInterface) {
        functionalInterface.doWork();
    }

    @Before
    public void setup() {
        this.spy = spy();
    }

    @Test
    public void has_one_callable_method() {
        callFunctionalInterface(() -> this.spy.invocation());

        assertThat(this.spy.invoked()).isTrue();
    }
}

--- 
+++ 
@@ -4,6 +4,7 @@
 import org.junit.Before;
 import org.junit.Test;
 
+import static es.sandbox.spikes.java8.FunctionalInterfaceCaller.call;
 import static es.sandbox.spikes.java8.InvocationSpy.spy;
 import static org.assertj.core.api.Assertions.assertThat;
 
@@ -14,10 +15,6 @@
 
     private InvocationSpy spy;
 
-    private static final void callFunctionalInterface(SimpleFunctionalInterface functionalInterface) {
-        functionalInterface.doWork();
-    }
-
     @Before
     public void setup() {
         this.spy = spy();
@@ -25,7 +22,7 @@
 
     @Test
     public void has_one_callable_method() {
-        callFunctionalInterface(() -> this.spy.invocation());
+        call(() -> this.spy.invocation());
 
         assertThat(this.spy.invoked()).isTrue();
     }
Refactor utility method to FunctionalInterfaceCaller
