<commit_before><commit_msg>Implemented fluent interface and methods to operate on SuperClass and test<commit_after>package pl.softwaremill.common.util;

import org.testng.annotations.Test;

import static org.testng.Assert.assertEquals;

public class RichObjectTest {

    @Test
    public void shouldSetupField() {
        // given
        Object expected = Integer.valueOf("1");

        // when
        MyObject actual = (MyObject) new RichObject(new MyObject(null, null)).set("myField", expected).unwrap();

        // then
        assertEquals(expected, actual.getMyField());
    }

    @Test
    public void shouldReturnFieldValue() {
        // given
        Object expected = Integer.valueOf("1");

        // when
        Object actual = new RichObject(new MyObject(null, expected)).get("myField");

        // then
        assertEquals(expected, actual);
    }

    @Test
    public void shouldSetupSuperField() {
        // given
        Object expected = Integer.valueOf("1");

        // when
        MyObject actual = (MyObject) new RichObject(new MyObject(expected, null)).setSuper("superField", expected).unwrap();

        // then
        assertEquals(expected, actual.getSuperField());
    }

    @Test
    public void shouldReturnSuperFieldValue() {
        // given
        Object expected = Integer.valueOf("1");

        // when
        Object actual = new RichObject(new MyObject(expected, null)).getSuper("superField");

        // then
        assertEquals(expected, actual);
    }

}

class MySuperObject {

    private Object superField;

    public MySuperObject(Object superField) {
        this.superField = superField;
    }

    public Object getSuperField() {
        return superField;
    }
}


class MyObject extends MySuperObject {

    private Object myField;

    public MyObject(Object superField, Object myField) {
        super(superField);
        this.myField = myField;
    }

    public Object getMyField() {
        return myField;
    }

}
{'fraction_non_alphanumeric': 0.10473313192346426, 'fraction_numerical': 0.002014098690835851, 'mean_word_length': 2.4982394366197185, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1092268', 'n_tokens_mistral': 535, 'n_tokens_neox': 516, 'n_words': 131}