Skip to content

Commit

Permalink
test(objectionary#1385): add test for DcsNoOneHashTransitive
Browse files Browse the repository at this point in the history
  • Loading branch information
volodya-lombrozo committed Nov 2, 2022
1 parent 8e04dfc commit 822baeb
Showing 1 changed file with 46 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package org.eolang.maven;

import java.util.Collections;
import org.apache.maven.model.Dependency;
import org.cactoos.scalar.LengthOf;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

class DcsNoOneHasTransitiveTest {

@Test
void checksAllDependenciesWithoutTransitive() throws Exception {
MatcherAssert.assertThat(
new LengthOf(
new DcsNoOneHasTransitive(single("eo-collections"), d -> empty())).value(),
Matchers.equalTo(1L)
);
}

@Test
void checksAllDependenciesWithTransitive() {
Assertions.assertThrows(
IllegalStateException.class,
new DcsNoOneHasTransitive(single("eo-foo"), d -> single("eo-bar"))::iterator
);
}

private Dependencies empty() {
return Collections::emptyIterator;
}

private Dependencies single(final String artifact) {
return () -> Collections.singletonList(dependency(artifact)).iterator();
}

private Dependency dependency(final String artifact) {
final Dependency dependency = new Dependency();
dependency.setGroupId("org.eolang");
dependency.setArtifactId(artifact);
dependency.setVersion("0.1.0");
dependency.setScope("compile");
return dependency;
}
}

0 comments on commit 822baeb

Please sign in to comment.