|
27 | 27 |
|
28 | 28 | import static org.hamcrest.CoreMatchers.instanceOf;
|
29 | 29 | import static org.junit.Assert.assertEquals;
|
| 30 | +import static org.junit.Assert.assertNotSame; |
30 | 31 | import static org.junit.Assert.assertNull;
|
31 | 32 | import static org.junit.Assert.assertSame;
|
32 | 33 | import static org.junit.Assert.assertThat;
|
@@ -66,6 +67,25 @@ public void testConstructors() {
|
66 | 67 | assertSame(builder, query.getBuilder());
|
67 | 68 | }
|
68 | 69 |
|
| 70 | + @Test |
| 71 | + public void testCopy() throws InterruptedException { |
| 72 | + ParseQuery<ParseObject> query = new ParseQuery<>("TestObject"); |
| 73 | + query.setUser(new ParseUser()); |
| 74 | + query.whereEqualTo("foo", "bar"); |
| 75 | + ParseQuery.State.Builder<ParseObject> builder = query.getBuilder(); |
| 76 | + ParseQuery.State<ParseObject> state = query.getBuilder().build(); |
| 77 | + |
| 78 | + ParseQuery<ParseObject> queryCopy = new ParseQuery<>(query); |
| 79 | + ParseQuery.State.Builder<ParseObject> builderCopy = queryCopy.getBuilder(); |
| 80 | + ParseQuery.State<ParseObject> stateCopy = queryCopy.getBuilder().build(); |
| 81 | + |
| 82 | + assertNotSame(query, queryCopy); |
| 83 | + assertSame(query.getUserAsync(state).getResult(), queryCopy.getUserAsync(stateCopy).getResult()); |
| 84 | + |
| 85 | + assertNotSame(builder, builderCopy); |
| 86 | + assertSame(state.constraints().get("foo"), stateCopy.constraints().get("foo")); |
| 87 | + } |
| 88 | + |
69 | 89 | // ParseUser#setUser is for tests only
|
70 | 90 | @Test
|
71 | 91 | public void testSetUser() throws ParseException {
|
|
0 commit comments