@Test public void testGetExpressionCountWithMultipleExpr() throws IOException { Assert.assertEquals(0, exprRepo.getExpressionCount(Organization.DEFAULT)); try (Transaction transaction = Ebean.beginTransaction()) { final models.ebean.Expression ebeanExpression1 = TestBeanFactory.createEbeanExpression(); ebeanExpression1.setUuid(UUID.randomUUID()); ebeanExpression1.setOrganization( models.ebean.Organization.findByOrganization(Organization.DEFAULT)); Ebean.save(ebeanExpression1); final models.ebean.Expression ebeanExpression2 = TestBeanFactory.createEbeanExpression(); ebeanExpression2.setUuid(UUID.randomUUID()); ebeanExpression2.setOrganization( models.ebean.Organization.findByOrganization(Organization.DEFAULT)); Ebean.save(ebeanExpression2); transaction.commit(); } Assert.assertEquals(2, exprRepo.getExpressionCount(Organization.DEFAULT)); }
@Test public void testGetForValidId() throws IOException { final UUID uuid = UUID.randomUUID(); Assert.assertFalse(exprRepo.get(uuid, Organization.DEFAULT).isPresent()); final models.ebean.Expression ebeanExpression = TestBeanFactory.createEbeanExpression(); ebeanExpression.setUuid(uuid); ebeanExpression.setOrganization( models.ebean.Organization.findByOrganization(Organization.DEFAULT)); try (Transaction transaction = Ebean.beginTransaction()) { Ebean.save(ebeanExpression); transaction.commit(); } final Optional<Expression> expected = exprRepo.get(uuid, Organization.DEFAULT); Assert.assertTrue(expected.isPresent()); Assert.assertTrue(isExpressionEbeanEquivalent(expected.get(), ebeanExpression)); }