Example 1
    Source Project: presto File: TestResourceGroupsDao.java

    1. @Test
    2. public void testExactMatchSelector()
    3. {
    4. H2ResourceGroupsDao dao = setup("exact_match_selector");
    5. dao.createExactMatchSelectorsTable();
    6. ResourceGroupId resourceGroupId1 = new ResourceGroupId(ImmutableList.of("global", "test", "user", "insert"));
    7. ResourceGroupId resourceGroupId2 = new ResourceGroupId(ImmutableList.of("global", "test", "user", "select"));
    8. JsonCodec<ResourceGroupId> codec = JsonCodec.jsonCodec(ResourceGroupId.class);
    9. dao.insertExactMatchSelector("test", "@test@test_pipeline", INSERT.name(), codec.toJson(resourceGroupId1));
    10. dao.insertExactMatchSelector("test", "@test@test_pipeline", SELECT.name(), codec.toJson(resourceGroupId2));
    11. assertNull(dao.getExactMatchResourceGroup("test", "@test@test_pipeline", null));
    12. assertEquals(dao.getExactMatchResourceGroup("test", "@test@test_pipeline", INSERT.name()), codec.toJson(resourceGroupId1));
    13. assertEquals(dao.getExactMatchResourceGroup("test", "@test@test_pipeline", SELECT.name()), codec.toJson(resourceGroupId2));
    14. assertNull(dao.getExactMatchResourceGroup("test", "@test@test_pipeline", DELETE.name()));
    15. assertNull(dao.getExactMatchResourceGroup("test", "abc", INSERT.name()));
    16. assertNull(dao.getExactMatchResourceGroup("prod", "@test@test_pipeline", INSERT.name()));
    17. }

    Example 2

    1. @Test
    2. public void testJson()
    3. {
    4. JsonCodec<PipelineStats> codec = JsonCodec.jsonCodec(PipelineStats.class);
    5. String json = codec.toJson(EXPECTED);
    6. PipelineStats actual = codec.fromJson(json);
    7. assertExpectedPipelineStats(actual);
    8. }