@Test public void assertFailWithout() { Assert.assertArrayEquals( new String[] { "goals missing", "[g2]" }, SrcdepsEnforcer.assertFailWithout( MavenAssertions.failWithoutBuilder() .goal("g1").goal("g2") .build(), Arrays.asList("g1"), Collections.<String>emptyList(), new Properties() ) ); Assert.assertArrayEquals( new String[] { "profiles missing", "[p3, p4]" }, SrcdepsEnforcer.assertFailWithout( MavenAssertions.failWithoutBuilder() .profile("p3").profile("p4") .build(), Arrays.asList("g1", "g2"), Arrays.asList("p1", "p2"), new Properties() { { put("key1", "val1"); put("key2", "val2"); } } ) ); Assert.assertArrayEquals( new String[] { "properties missing", "[key3]" }, SrcdepsEnforcer.assertFailWithout( MavenAssertions.failWithoutBuilder() .property("key3") .build(), Arrays.asList("g1", "g2"), Arrays.asList("p1", "p2"), new Properties() { { put("key1", "val1"); put("key2", "val2"); } } ) ); Assert.assertArrayEquals( new String[] { "properties missing", "[key3=val3]" }, SrcdepsEnforcer.assertFailWithout( MavenAssertions.failWithoutBuilder() .property("key3=val3") .build(), Arrays.asList("g1", "g2"), Arrays.asList("p1", "p2"), new Properties() { { put("key1", "val1"); put("key2", "val2"); } } ) ); Assert.assertNull( SrcdepsEnforcer.assertFailWithout( MavenAssertions.failWithoutBuilder() .build(), Arrays.asList("g1", "g2"), Arrays.asList("p1", "p2"), new Properties() { { put("key1", "val1"); put("key2", "val2"); } } ) ); Assert.assertNull( SrcdepsEnforcer.assertFailWithout( MavenAssertions.failWithoutBuilder() .goal("g1") .profile("p1") .property("key1") .build(), Arrays.asList("g1", "g2"), Arrays.asList("p1", "p2"), new Properties() { { put("key1", "val1"); put("key2", "val2"); } } ) ); }
static String[] assertFailWithout(MavenAssertions failWithout, List<String> goals, List<String> profiles, Properties properties) { log.debug("srcdeps: The enforcer is using failWithout [{}]", failWithout); final Set<String> failWithoutGoals = new LinkedHashSet<>(failWithout.getGoals()); failWithoutGoals.removeAll(goals); if (!failWithoutGoals.isEmpty()) { return new String[] { "goals missing", failWithoutGoals.toString() }; } final Set<String> failWithoutProfiles = new LinkedHashSet<>(failWithout.getProfiles()); failWithoutProfiles.removeAll(profiles); if (!failWithoutProfiles.isEmpty()) { return new String[] { "profiles missing", failWithoutProfiles.toString() }; } final Set<String> failWithoutProperties = new LinkedHashSet<>(failWithout.getProperties()); for (Entry<Object, Object> prop : properties.entrySet()) { final String key = prop.getKey().toString(); failWithoutProperties.remove(key); final Object val = prop.getValue(); if (val != null) { failWithoutProperties.remove(key + "=" + val.toString()); } } if (!failWithoutProperties.isEmpty()) { return new String[] { "properties missing", failWithoutProperties.toString() }; } return null; }
SrcdepsEnforcer implements ProjectExecutionListener { static String[] assertFailWithout(MavenAssertions failWithout, List<String> goals, List<String> profiles, Properties properties) { log.debug("srcdeps: The enforcer is using failWithout [{}]", failWithout); final Set<String> failWithoutGoals = new LinkedHashSet<>(failWithout.getGoals()); failWithoutGoals.removeAll(goals); if (!failWithoutGoals.isEmpty()) { return new String[] { "goals missing", failWithoutGoals.toString() }; } final Set<String> failWithoutProfiles = new LinkedHashSet<>(failWithout.getProfiles()); failWithoutProfiles.removeAll(profiles); if (!failWithoutProfiles.isEmpty()) { return new String[] { "profiles missing", failWithoutProfiles.toString() }; } final Set<String> failWithoutProperties = new LinkedHashSet<>(failWithout.getProperties()); for (Entry<Object, Object> prop : properties.entrySet()) { final String key = prop.getKey().toString(); failWithoutProperties.remove(key); final Object val = prop.getValue(); if (val != null) { failWithoutProperties.remove(key + "=" + val.toString()); } } if (!failWithoutProperties.isEmpty()) { return new String[] { "properties missing", failWithoutProperties.toString() }; } return null; } }
SrcdepsEnforcer implements ProjectExecutionListener { static String[] assertFailWithout(MavenAssertions failWithout, List<String> goals, List<String> profiles, Properties properties) { log.debug("srcdeps: The enforcer is using failWithout [{}]", failWithout); final Set<String> failWithoutGoals = new LinkedHashSet<>(failWithout.getGoals()); failWithoutGoals.removeAll(goals); if (!failWithoutGoals.isEmpty()) { return new String[] { "goals missing", failWithoutGoals.toString() }; } final Set<String> failWithoutProfiles = new LinkedHashSet<>(failWithout.getProfiles()); failWithoutProfiles.removeAll(profiles); if (!failWithoutProfiles.isEmpty()) { return new String[] { "profiles missing", failWithoutProfiles.toString() }; } final Set<String> failWithoutProperties = new LinkedHashSet<>(failWithout.getProperties()); for (Entry<Object, Object> prop : properties.entrySet()) { final String key = prop.getKey().toString(); failWithoutProperties.remove(key); final Object val = prop.getValue(); if (val != null) { failWithoutProperties.remove(key + "=" + val.toString()); } } if (!failWithoutProperties.isEmpty()) { return new String[] { "properties missing", failWithoutProperties.toString() }; } return null; } @Inject  SrcdepsEnforcer(ConfigurationProducer configurationProducer); }
SrcdepsEnforcer implements ProjectExecutionListener { static String[] assertFailWithout(MavenAssertions failWithout, List<String> goals, List<String> profiles, Properties properties) { log.debug("srcdeps: The enforcer is using failWithout [{}]", failWithout); final Set<String> failWithoutGoals = new LinkedHashSet<>(failWithout.getGoals()); failWithoutGoals.removeAll(goals); if (!failWithoutGoals.isEmpty()) { return new String[] { "goals missing", failWithoutGoals.toString() }; } final Set<String> failWithoutProfiles = new LinkedHashSet<>(failWithout.getProfiles()); failWithoutProfiles.removeAll(profiles); if (!failWithoutProfiles.isEmpty()) { return new String[] { "profiles missing", failWithoutProfiles.toString() }; } final Set<String> failWithoutProperties = new LinkedHashSet<>(failWithout.getProperties()); for (Entry<Object, Object> prop : properties.entrySet()) { final String key = prop.getKey().toString(); failWithoutProperties.remove(key); final Object val = prop.getValue(); if (val != null) { failWithoutProperties.remove(key + "=" + val.toString()); } } if (!failWithoutProperties.isEmpty()) { return new String[] { "properties missing", failWithoutProperties.toString() }; } 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[] assertFailWithout(MavenAssertions failWithout, List<String> goals, List<String> profiles, Properties properties) { log.debug("srcdeps: The enforcer is using failWithout [{}]", failWithout); final Set<String> failWithoutGoals = new LinkedHashSet<>(failWithout.getGoals()); failWithoutGoals.removeAll(goals); if (!failWithoutGoals.isEmpty()) { return new String[] { "goals missing", failWithoutGoals.toString() }; } final Set<String> failWithoutProfiles = new LinkedHashSet<>(failWithout.getProfiles()); failWithoutProfiles.removeAll(profiles); if (!failWithoutProfiles.isEmpty()) { return new String[] { "profiles missing", failWithoutProfiles.toString() }; } final Set<String> failWithoutProperties = new LinkedHashSet<>(failWithout.getProperties()); for (Entry<Object, Object> prop : properties.entrySet()) { final String key = prop.getKey().toString(); failWithoutProperties.remove(key); final Object val = prop.getValue(); if (val != null) { failWithoutProperties.remove(key + "=" + val.toString()); } } if (!failWithoutProperties.isEmpty()) { return new String[] { "properties missing", failWithoutProperties.toString() }; } 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);  }