<commit_before>package net.openhft.chronicle.wire;

import net.openhft.chronicle.bytes.Bytes;
import net.openhft.chronicle.core.annotation.UsedViaReflection;
import org.jetbrains.annotations.NotNull;
import org.junit.Assert;
import org.junit.Test;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * @author <NAME>.
 */
public class InnerMapTest {

    static class MyMarshable extends AbstractMarshallable {


        String name;

        Map<String, Double> commission;


        @UsedViaReflection
        public MyMarshable(@NotNull WireIn wire) {
            readMarshallable(wire);
        }

        public MyMarshable() {
            this.commission = new LinkedHashMap<>();
        }

        public String name() {
            return name;
        }

        public Map<String, Double> commission() {
            return commission;
        }

        public MyMarshable name(String name) {
            this.name = name;
            return this;
        }
    }


    @Test
    public void testMyInnnerMap() {
        MyMarshable myMarshable = new MyMarshable().name("rob");
        myMarshable.commission().put("hello", 123.4);

        String asString = myMarshable.toString();
        Assert.assertEquals("!net.openhft.chronicle.wire.InnerMapTest$MyMarshable {\n" +
                "  name: rob,\n" +
                "  commission: {\n" +
                "    hello: 123.4\n" +
                "  }\n" +
                "}\n", asString);


        Bytes b = Bytes.elasticByteBuffer();
        Wire w = new BinaryWire(b);     // works with text fails with binary

        try (DocumentContext dc = w.writingDocument(false)) {
            dc.wire().write("marshable").typedMarshallable(myMarshable);
        }


        try (DocumentContext dc = w.readingDocument()) {
            MyMarshable tm = dc.wire().read(() -> "marshable").typedMarshallable();
            Assert.assertEquals(asString, tm.toString());
        }

    }
}<commit_msg>FIx hanlding of nested collections and deprecate duplicate Map writing/reading methods.<commit_after>package net.openhft.chronicle.wire;

import net.openhft.chronicle.bytes.Bytes;
import net.openhft.chronicle.core.annotation.UsedViaReflection;
import org.jetbrains.annotations.NotNull;
import org.junit.Assert;
import org.junit.Test;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * @author <NAME>.
 */
public class InnerMapTest {

    @Test
    public void testMyInnnerMap() {
        MyMarshable myMarshable = new MyMarshable().name("rob");
        myMarshable.commission().put("hello", 123.4);

        String asString = myMarshable.toString();
        Assert.assertEquals("!net.openhft.chronicle.wire.InnerMapTest$MyMarshable {\n" +
                "  name: rob,\n" +
                "  commission: {\n" +
                "    hello: 123.4\n" +
                "  }\n" +
                "}\n", asString);

        Bytes b = Bytes.elasticByteBuffer();
        Wire w = new BinaryWire(b);     // works with text fails with binary

        try (DocumentContext dc = w.writingDocument(false)) {
            dc.wire().write("marshable").typedMarshallable(myMarshable);
        }

        try (DocumentContext dc = w.readingDocument()) {
            MyMarshable tm = dc.wire().read(() -> "marshable").typedMarshallable();
            Assert.assertEquals(asString, tm.toString());
        }

    }

    static class MyMarshable extends AbstractMarshallable implements Demarshallable {
        String name;
        Map<String, Double> commission;

        @UsedViaReflection
        public MyMarshable(@NotNull WireIn wire) {
            readMarshallable(wire);
        }

        public MyMarshable() {
            this.commission = new LinkedHashMap<>();
        }

        public String name() {
            return name;
        }

        public Map<String, Double> commission() {
            return commission;
        }

        public MyMarshable name(String name) {
            this.name = name;
            return this;
        }
    }
}
{'fraction_non_alphanumeric': 0.11545160487683503, 'fraction_numerical': 0.003981089823339139, 'mean_word_length': 2.12111801242236, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6437591', 'n_tokens_mistral': 1203, 'n_tokens_neox': 1131, 'n_words': 238}