@Test public void testRelativeLabel() throws Exception { assertEquals(Label.parseAbsolute("//quux:wiz"), Type.LABEL.convert(":wiz", null, currentRule)); assertEquals(Label.parseAbsolute("//quux:wiz"), Type.LABEL.convert("wiz", null, currentRule)); try { Type.LABEL.convert("wiz", null); fail(); } catch (NullPointerException e) { /* ok */ } }
@Test public void testNonLabel() throws Exception { try { Type.LABEL.convert(3, null); fail(); } catch (Type.ConversionException e) { assertThat(e).hasMessage("expected value of type 'string', but got 3 (int)"); } }
@Test public void testInvalidLabel() throws Exception { try { Type.LABEL.convert("not a label", null, currentRule); fail(); } catch (Type.ConversionException e) { MoreAsserts.assertContainsWordsWithQuotes(e.getMessage(), "not a label"); } }
@Test public void testLabel() throws Exception { Label label = Label.parseAbsolute("//foo:bar"); assertEquals(label, Type.LABEL.convert("//foo:bar", null, currentRule)); assertThat(Type.LABEL.flatten(label)).containsExactly(label); }