@Test
 public void testHasMavenCoordinatesBuildRuleMissingCoordinates() throws Exception {
   BuildRule rule =
       JavaLibraryBuilder.createBuilder(BuildTargetFactory.newInstance("//test:no-mvn"))
           .build(resolver);
   try {
     expander.getMavenCoordinates(rule);
     fail("Expected MacroException; Rule does not contain maven coordinates");
   } catch (MacroException e) {
     assertTrue(
         "Expected MacroException that indicates target does not have maven coordinates",
         e.getMessage().contains("does not have maven coordinates"));
   }
 }
  @Test
  public void testHasMavenCoordinatesBuildRule() throws Exception {

    String mavenCoords = "org.foo:bar:1.0";

    BuildRule rule =
        JavaLibraryBuilder.createBuilder(BuildTargetFactory.newInstance("//test:java"))
            .setMavenCoords(mavenCoords)
            .build(resolver);
    try {
      String actualCoords = expander.getMavenCoordinates(rule);
      assertEquals(
          "Return maven coordinates do not match provides ones", mavenCoords, actualCoords);
    } catch (MacroException e) {
      fail(String.format("Unexpected MacroException: %s", e.getMessage()));
    }
  }
  @Test
  public void testNonHasMavenCoordinatesBuildRule() throws Exception {
    assumeFalse(
        "Assuming that FakeBuildRule does not have maven coordinates",
        FakeBuildRule.class.isInstance(HasMavenCoordinates.class));

    SourcePathResolver sourcePathResolver = new SourcePathResolver(resolver);
    BuildRule rule = new FakeBuildRule("//test:foo", sourcePathResolver);

    try {
      expander.getMavenCoordinates(rule);
      fail("Expected MacroException; Rule does not contain maven coordinates");
    } catch (MacroException e) {
      assertTrue(
          "Expected MacroException that indicates target does not have maven coordinates",
          e.getMessage().contains("does not correspond to a rule with maven coordinates"));
    }
  }