/** Tests basic {@link Type.Selector} functionality. */ @Test public void testSelector() throws Exception { Object input = ImmutableMap.of( "//conditions:a", "//a:a", "//conditions:b", "//b:b", Type.Selector.DEFAULT_CONDITION_KEY, "//d:d"); Type.Selector<Label> selector = new Type.Selector<>(input, null, currentRule, Type.LABEL); assertEquals(Type.LABEL, selector.getOriginalType()); Map<Label, Label> expectedMap = ImmutableMap.of( Label.parseAbsolute("//conditions:a"), Label.create("a", "a"), Label.parseAbsolute("//conditions:b"), Label.create("b", "b"), Label.parseAbsolute(Type.Selector.DEFAULT_CONDITION_KEY), Label.create("d", "d")); assertSameContents(expectedMap.entrySet(), selector.getEntries().entrySet()); }
/** Tests for "reserved" key labels (i.e. not intended to map to actual targets). */ @Test public void testReservedKeyLabels() throws Exception { assertFalse(Type.Selector.isReservedLabel(Label.parseAbsolute("//condition:a"))); assertTrue( Type.Selector.isReservedLabel(Label.parseAbsolute(Type.Selector.DEFAULT_CONDITION_KEY))); }