Example 1
Source Project: presto File: TestResourceGroupsDao.java
@Testpublic void testExactMatchSelector(){H2ResourceGroupsDao dao = setup("exact_match_selector");dao.createExactMatchSelectorsTable();ResourceGroupId resourceGroupId1 = new ResourceGroupId(ImmutableList.of("global", "test", "user", "insert"));ResourceGroupId resourceGroupId2 = new ResourceGroupId(ImmutableList.of("global", "test", "user", "select"));JsonCodec<ResourceGroupId> codec = JsonCodec.jsonCodec(ResourceGroupId.class);dao.insertExactMatchSelector("test", "@test@test_pipeline", INSERT.name(), codec.toJson(resourceGroupId1));dao.insertExactMatchSelector("test", "@test@test_pipeline", SELECT.name(), codec.toJson(resourceGroupId2));assertNull(dao.getExactMatchResourceGroup("test", "@test@test_pipeline", null));assertEquals(dao.getExactMatchResourceGroup("test", "@test@test_pipeline", INSERT.name()), codec.toJson(resourceGroupId1));assertEquals(dao.getExactMatchResourceGroup("test", "@test@test_pipeline", SELECT.name()), codec.toJson(resourceGroupId2));assertNull(dao.getExactMatchResourceGroup("test", "@test@test_pipeline", DELETE.name()));assertNull(dao.getExactMatchResourceGroup("test", "abc", INSERT.name()));assertNull(dao.getExactMatchResourceGroup("prod", "@test@test_pipeline", INSERT.name()));}
Example 2
@Testpublic void testJson(){JsonCodec<PipelineStats> codec = JsonCodec.jsonCodec(PipelineStats.class);String json = codec.toJson(EXPECTED);PipelineStats actual = codec.fromJson(json);assertExpectedPipelineStats(actual);}
