/** * Method: equals(Object obj) */ @Test public void testEquals() { DataQuery query1 = DataQuery.of("test"); DataQuery query2 = DataQuery.of("test"); DataQuery nonEqual = DataQuery.of("nope"); assertThat(query1.equals(query1), is(true)); assertThat(query1.equals(query2), is(true)); assertThat(query1.equals(nonEqual), is(false)); }
/** * Method: of(char separator, String path) */ @Test public void testOfForSeparatorPath() { DataQuery first = DataQuery.of('.', "this.test.equals"); DataQuery second = DataQuery.of(',', "this,test,equals"); DataQuery complex = DataQuery.of('\u8482', "this\u8482test\u8482equals"); DataQuery test = DataQuery.of("this", "test", "equals"); assertThat(first.equals(test), is(true)); assertThat(first.equals(second), is(true)); assertThat(first.equals(complex), is(true)); assertThat(second.equals(complex), is(true)); assertThat(second.equals(first), is(true)); assertThat(second.equals(test), is(true)); }
/** * Method: then(DataQuery that) */ @Test public void testThen() { final DataQuery query = DataQuery.of("this", "testing"); final DataQuery other = DataQuery.of("this"); final DataQuery test = other.then(DataQuery.of("testing")); assertThat(query.equals(test), is(true)); assertThat(test.equals(query), is(true)); }
/** * Method: pop() */ @Test public void testPop() { DataQuery prePopped = DataQuery.of("this", "test", "query"); DataQuery expected = DataQuery.of("this", "test"); assertThat(prePopped.pop().equals(expected), is(true)); DataQuery empty = DataQuery.of(); DataQuery emptyPopped = empty.pop(); assertThat(emptyPopped.equals(empty), is(true)); DataQuery single = DataQuery.of("single"); assertThat(single.pop().equals(empty), is(true)); }