### Question:
ResolverQueryOrderBy implements OrderByResolver<Query, Query> { @Override public Query resolve(OrderByClause orderByClause, Query target) { switch (orderByClause.getOrderByMode()) { case ORDER_BY_CHILD: if (orderByClause.getArgument() == null) { throw new IllegalArgumentException(MISSING_ARGUMENT); } return target.orderByChild(orderByClause.getArgument()); case ORDER_BY_KEY: return target.orderByKey(); case ORDER_BY_VALUE: return target.orderByValue(); default: throw new IllegalStateException(); } }  @Override Query resolve(OrderByClause orderByClause, Query target);  }### Answer:
@Test public void resolve_orderByChild() { OrderByClause orderByClause = new OrderByClause(); orderByClause.setOrderByMode(OrderByMode.ORDER_BY_CHILD); orderByClause.setArgument("test_argument"); Query query = PowerMockito.mock(Query.class); ResolverQueryOrderBy resolver = new ResolverQueryOrderBy(); resolver.resolve(orderByClause, query); Mockito.verify(query, VerificationModeFactory.times(1)).orderByChild(Mockito.eq("test_argument")); }
@Test(expected = IllegalArgumentException.class) public void resolve_orderByChild_withoutArgument() { OrderByClause orderByClause = new OrderByClause(); orderByClause.setOrderByMode(OrderByMode.ORDER_BY_CHILD); Query query = PowerMockito.mock(Query.class); ResolverQueryOrderBy resolver = new ResolverQueryOrderBy(); resolver.resolve(orderByClause, query); Mockito.verify(query, VerificationModeFactory.times(1)).orderByChild(Mockito.eq("test_argument")); }
@Test public void resolve_orderByKey() { OrderByClause orderByClause = new OrderByClause(); orderByClause.setOrderByMode(OrderByMode.ORDER_BY_KEY); Query query = PowerMockito.mock(Query.class); ResolverQueryOrderBy resolver = new ResolverQueryOrderBy(); resolver.resolve(orderByClause, query); Mockito.verify(query, VerificationModeFactory.times(1)).orderByKey(); }
@Test public void resolve_orderByValue() { OrderByClause orderByClause = new OrderByClause(); orderByClause.setOrderByMode(OrderByMode.ORDER_BY_VALUE); Query query = PowerMockito.mock(Query.class); ResolverQueryOrderBy resolver = new ResolverQueryOrderBy(); resolver.resolve(orderByClause, query); Mockito.verify(query, VerificationModeFactory.times(1)).orderByValue(); }