package net.openhft.chronicle.wire.method;

import net.openhft.chronicle.bytes.Bytes;
import net.openhft.chronicle.wire.TextWire;
import org.junit.Test;

import static org.junit.Assert.assertEquals;

interface WithDefault {
    void method1(String text);

    default void method2(String text2) {
    }
}

public class DefaultMethodHandlingTest {
    @Test
    public void withDefault() {
        TextWire wire = new TextWire(Bytes.allocateElasticOnHeap());
        WithDefault withDefault = wire.methodWriter(WithDefault.class);
        withDefault.method1("one");
        withDefault.method2("two");
        assertEquals("method1: one\n" +
                "...\n" +
                "method2: two\n" +
                "...\n", wire.toString());
    }
}

@@ -79,16 +79,107 @@
 .Bytes;%0A
+import net.openhft.chronicle.bytes.MethodReader;%0Aimport net.openhft.chronicle.core.Mocker;%0A
 import n
@@ -238,16 +238,46 @@
 .Test;%0A%0A
+import java.io.StringWriter;%0A%0A
 import s
@@ -299,28 +299,17 @@
 .Assert.
-assertEquals
+*
 ;%0A%0Ainter
@@ -396,24 +396,75 @@
 ng text2) %7B%0A
+        throw new UnsupportedOperationException();%0A
     %7D%0A%7D%0A%0Apub
@@ -895,21 +895,383 @@
 toString());
+%0A%0A        StringWriter sw = new StringWriter();%0A        MethodReader reader = wire.methodReader(Mocker.logging(WithDefault.class, %22%22, sw));%0A        assertTrue(reader.readOne());%0A        assertTrue(reader.readOne());%0A        assertFalse(reader.readOne());%0A        assertEquals(%22method1%5Bone%5D%5Cn%22 +%0A                %22method2%5Btwo%5D%5Cn%22, sw.toString().replace(%22%5Cr%22, %22%22));
 %0A    %7D%0A%7D%0A

check MethodReader default methods