@Test
 public void testQueryClauseWithLimit() {
   final Expression expr1 =
       TestBeanFactory.createExpressionBuilder()
           .setId(UUID.randomUUID())
           .setService("my-test-service")
           .setCluster("my-test-cluster")
           .build();
   final Expression expr2 =
       TestBeanFactory.createExpressionBuilder()
           .setId(UUID.randomUUID())
           .setService("my-test-service")
           .setCluster("my-test-cluster")
           .build();
   exprRepo.addOrUpdateExpression(expr1, Organization.DEFAULT);
   exprRepo.addOrUpdateExpression(expr2, Organization.DEFAULT);
   final ExpressionQuery query1 = new DefaultExpressionQuery(exprRepo, Organization.DEFAULT);
   query1.service(Optional.of("my-test-service"));
   query1.cluster(Optional.of("my-test-cluster"));
   query1.limit(1);
   final QueryResult<Expression> result1 = exprRepo.query(query1);
   Assert.assertEquals(1, result1.values().size());
   final ExpressionQuery query2 = new DefaultExpressionQuery(exprRepo, Organization.DEFAULT);
   query2.service(Optional.of("my-test-service"));
   query2.cluster(Optional.of("my-test-cluster"));
   query2.limit(2);
   final QueryResult<Expression> result2 = exprRepo.query(query2);
   Assert.assertEquals(2, result2.values().size());
 }
 @Test
 public void testQueryWithContainsAndServiceClause() {
   final Expression expr1 =
       TestBeanFactory.createExpressionBuilder()
           .setId(UUID.randomUUID())
           .setMetric("my-contained-metric")
           .setService("my-service")
           .build();
   final Expression expr2 =
       TestBeanFactory.createExpressionBuilder()
           .setId(UUID.randomUUID())
           .setScript("my-contained-script")
           .setService("my-service")
           .build();
   final Expression expr3 =
       TestBeanFactory.createExpressionBuilder().setId(UUID.randomUUID()).build();
   exprRepo.addOrUpdateExpression(expr1, Organization.DEFAULT);
   exprRepo.addOrUpdateExpression(expr2, Organization.DEFAULT);
   exprRepo.addOrUpdateExpression(expr3, Organization.DEFAULT);
   final ExpressionQuery query = new DefaultExpressionQuery(exprRepo, Organization.DEFAULT);
   query.contains(Optional.of("contained"));
   query.service(Optional.of("my-service"));
   final QueryResult<Expression> result = exprRepo.query(query);
   Assert.assertEquals(2, result.values().size());
   Assert.assertEquals(expr1.getId(), result.values().get(0).getId());
   Assert.assertEquals(expr2.getId(), result.values().get(1).getId());
 }
 @Test
 public void testQueryClauseWithOffsetAndLimit() {
   final Expression expr1 =
       TestBeanFactory.createExpressionBuilder()
           .setId(UUID.randomUUID())
           .setService("my-test-service")
           .setCluster("my-test-cluster")
           .build();
   final Expression expr2 =
       TestBeanFactory.createExpressionBuilder()
           .setId(UUID.randomUUID())
           .setService("my-test-service")
           .setCluster("my-test-cluster")
           .build();
   final Expression expr3 =
       TestBeanFactory.createExpressionBuilder()
           .setId(UUID.randomUUID())
           .setService("my-test-service")
           .setCluster("my-test-cluster")
           .build();
   exprRepo.addOrUpdateExpression(expr1, Organization.DEFAULT);
   exprRepo.addOrUpdateExpression(expr2, Organization.DEFAULT);
   exprRepo.addOrUpdateExpression(expr3, Organization.DEFAULT);
   final ExpressionQuery query = new DefaultExpressionQuery(exprRepo, Organization.DEFAULT);
   query.service(Optional.of("my-test-service"));
   query.cluster(Optional.of("my-test-cluster"));
   query.offset(Optional.of(2));
   query.limit(2);
   final QueryResult<Expression> result = exprRepo.query(query);
   Assert.assertEquals(1, result.values().size());
   Assert.assertEquals(expr3.getId(), result.values().get(0).getId());
 }
 @Test
 public void testQueryClauseWithServiceOnly() {
   final Expression expr1 =
       TestBeanFactory.createExpressionBuilder()
           .setId(UUID.randomUUID())
           .setService("my-test-service")
           .build();
   final Expression expr2 =
       TestBeanFactory.createExpressionBuilder().setId(UUID.randomUUID()).build();
   exprRepo.addOrUpdateExpression(expr1, Organization.DEFAULT);
   exprRepo.addOrUpdateExpression(expr2, Organization.DEFAULT);
   final ExpressionQuery successQuery = new DefaultExpressionQuery(exprRepo, Organization.DEFAULT);
   successQuery.service(Optional.of("my-test-service"));
   final QueryResult<Expression> successResult = exprRepo.query(successQuery);
   Assert.assertEquals(1, successResult.total());
   final ExpressionQuery failQuery = new DefaultExpressionQuery(exprRepo, Organization.DEFAULT);
   failQuery.cluster(Optional.of("some-random-service"));
   final QueryResult<Expression> failResult = exprRepo.query(failQuery);
   Assert.assertEquals(0, failResult.total());
 }