@Test public void assertFailWith() { Assert.assertArrayEquals( new String[] { "goal", "g1" }, SrcdepsEnforcer.assertFailWith( MavenAssertions.failWithBuilder() .addDefaults(false) .goal("g1").goal("g2") .build(), Arrays.asList("g1"), Collections.<String>emptyList(), new Properties() ) ); Assert.assertArrayEquals( new String[] { "profile", "p2" }, SrcdepsEnforcer.assertFailWith( MavenAssertions.failWithBuilder() .addDefaults(false) .profile("p2") .build(), Arrays.asList("g1", "g2"), Arrays.asList("p1", "p2"), new Properties() { { put("key1", "val1"); put("key2", "val2"); } } ) ); Assert.assertArrayEquals( new String[] { "property", "key1" }, SrcdepsEnforcer.assertFailWith( MavenAssertions.failWithBuilder() .addDefaults(false) .property("key1") .build(), Arrays.asList("g1", "g2"), Arrays.asList("p1", "p2"), new Properties() { { put("key1", "val1"); put("key2", "val2"); } } ) ); Assert.assertArrayEquals( new String[] { "property", "key1=val1" }, SrcdepsEnforcer.assertFailWith( MavenAssertions.failWithBuilder() .addDefaults(false) .property("key1=val1") .build(), Arrays.asList("g1", "g2"), Arrays.asList("p1", "p2"), new Properties() { { put("key1", "val1"); put("key2", "val2"); } } ) ); Assert.assertNull( SrcdepsEnforcer.assertFailWith( MavenAssertions.failWithBuilder() .addDefaults(false) .build(), Arrays.asList("g1", "g2"), Arrays.asList("p1", "p2"), new Properties() { { put("key1", "val1"); put("key2", "val2"); } } ) ); Assert.assertNull( SrcdepsEnforcer.assertFailWith( MavenAssertions.failWithBuilder() .addDefaults(false) .goal("g3") .profile("p3") .property("key3") .build(), Arrays.asList("g1", "g2"), Arrays.asList("p1", "p2"), new Properties() { { put("key1", "val1"); put("key2", "val2"); } } ) ); }
static String[] assertFailWith(MavenAssertions failWith, List<String> goals, List<String> profiles, Properties properties) { log.debug("srcdeps: The enforcer is using failWith [{}]", failWith); final Set<String> failWithGoals = failWith.getGoals(); for (String goal : goals) { if (failWithGoals.contains(goal)) { return new String[] { "goal", goal }; } } final Set<String> failWithProfiles = failWith.getProfiles(); for (String profile : profiles) { if (failWithProfiles.contains(profile)) { return new String[] { "profile", profile }; } } final Set<String> failWithProperties = failWith.getProperties(); for (String keyVal : failWithProperties) { final int eqPos = keyVal.indexOf('='); final String key; final String val; if (eqPos >= 0) { key = keyVal.substring(0, eqPos); val = keyVal.substring(eqPos + 1); if (val.equals(properties.get(key))) { return new String[] { "property", keyVal }; } } else { key = keyVal; if (properties.containsKey(key)) { return new String[] { "property", keyVal }; } } } return null; }
SrcdepsEnforcer implements ProjectExecutionListener { static String[] assertFailWith(MavenAssertions failWith, List<String> goals, List<String> profiles, Properties properties) { log.debug("srcdeps: The enforcer is using failWith [{}]", failWith); final Set<String> failWithGoals = failWith.getGoals(); for (String goal : goals) { if (failWithGoals.contains(goal)) { return new String[] { "goal", goal }; } } final Set<String> failWithProfiles = failWith.getProfiles(); for (String profile : profiles) { if (failWithProfiles.contains(profile)) { return new String[] { "profile", profile }; } } final Set<String> failWithProperties = failWith.getProperties(); for (String keyVal : failWithProperties) { final int eqPos = keyVal.indexOf('='); final String key; final String val; if (eqPos >= 0) { key = keyVal.substring(0, eqPos); val = keyVal.substring(eqPos + 1); if (val.equals(properties.get(key))) { return new String[] { "property", keyVal }; } } else { key = keyVal; if (properties.containsKey(key)) { return new String[] { "property", keyVal }; } } } return null; } }
SrcdepsEnforcer implements ProjectExecutionListener { static String[] assertFailWith(MavenAssertions failWith, List<String> goals, List<String> profiles, Properties properties) { log.debug("srcdeps: The enforcer is using failWith [{}]", failWith); final Set<String> failWithGoals = failWith.getGoals(); for (String goal : goals) { if (failWithGoals.contains(goal)) { return new String[] { "goal", goal }; } } final Set<String> failWithProfiles = failWith.getProfiles(); for (String profile : profiles) { if (failWithProfiles.contains(profile)) { return new String[] { "profile", profile }; } } final Set<String> failWithProperties = failWith.getProperties(); for (String keyVal : failWithProperties) { final int eqPos = keyVal.indexOf('='); final String key; final String val; if (eqPos >= 0) { key = keyVal.substring(0, eqPos); val = keyVal.substring(eqPos + 1); if (val.equals(properties.get(key))) { return new String[] { "property", keyVal }; } } else { key = keyVal; if (properties.containsKey(key)) { return new String[] { "property", keyVal }; } } } return null; } @Inject  SrcdepsEnforcer(ConfigurationProducer configurationProducer); }
SrcdepsEnforcer implements ProjectExecutionListener { static String[] assertFailWith(MavenAssertions failWith, List<String> goals, List<String> profiles, Properties properties) { log.debug("srcdeps: The enforcer is using failWith [{}]", failWith); final Set<String> failWithGoals = failWith.getGoals(); for (String goal : goals) { if (failWithGoals.contains(goal)) { return new String[] { "goal", goal }; } } final Set<String> failWithProfiles = failWith.getProfiles(); for (String profile : profiles) { if (failWithProfiles.contains(profile)) { return new String[] { "profile", profile }; } } final Set<String> failWithProperties = failWith.getProperties(); for (String keyVal : failWithProperties) { final int eqPos = keyVal.indexOf('='); final String key; final String val; if (eqPos >= 0) { key = keyVal.substring(0, eqPos); val = keyVal.substring(eqPos + 1); if (val.equals(properties.get(key))) { return new String[] { "property", keyVal }; } } else { key = keyVal; if (properties.containsKey(key)) { return new String[] { "property", keyVal }; } } } return null; } @Inject  SrcdepsEnforcer(ConfigurationProducer configurationProducer); @Override void afterProjectExecutionFailure(ProjectExecutionEvent event); @Override void afterProjectExecutionSuccess(ProjectExecutionEvent event); @Override void beforeProjectExecution(ProjectExecutionEvent event); @Override void beforeProjectLifecycleExecution(ProjectExecutionEvent event); }
SrcdepsEnforcer implements ProjectExecutionListener { static String[] assertFailWith(MavenAssertions failWith, List<String> goals, List<String> profiles, Properties properties) { log.debug("srcdeps: The enforcer is using failWith [{}]", failWith); final Set<String> failWithGoals = failWith.getGoals(); for (String goal : goals) { if (failWithGoals.contains(goal)) { return new String[] { "goal", goal }; } } final Set<String> failWithProfiles = failWith.getProfiles(); for (String profile : profiles) { if (failWithProfiles.contains(profile)) { return new String[] { "profile", profile }; } } final Set<String> failWithProperties = failWith.getProperties(); for (String keyVal : failWithProperties) { final int eqPos = keyVal.indexOf('='); final String key; final String val; if (eqPos >= 0) { key = keyVal.substring(0, eqPos); val = keyVal.substring(eqPos + 1); if (val.equals(properties.get(key))) { return new String[] { "property", keyVal }; } } else { key = keyVal; if (properties.containsKey(key)) { return new String[] { "property", keyVal }; } } } return null; } @Inject  SrcdepsEnforcer(ConfigurationProducer configurationProducer); @Override void afterProjectExecutionFailure(ProjectExecutionEvent event); @Override void afterProjectExecutionSuccess(ProjectExecutionEvent event); @Override void beforeProjectExecution(ProjectExecutionEvent event); @Override void beforeProjectLifecycleExecution(ProjectExecutionEvent event);  }