Skip to content

Commit

Permalink
feat(#1716): apply OyIndexed
Browse files Browse the repository at this point in the history
  • Loading branch information
volodya-lombrozo committed Feb 1, 2023
1 parent 18a3685 commit 282f4ad
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import org.eolang.maven.objectionary.Objectionary;
import org.eolang.maven.objectionary.OyFallbackSwap;
import org.eolang.maven.objectionary.OyHome;
import org.eolang.maven.objectionary.OyIndexed;
import org.eolang.maven.objectionary.OyRemote;
import org.eolang.maven.util.Online;
import org.eolang.maven.util.Rel;
Expand Down Expand Up @@ -128,7 +129,7 @@ public void exec() throws IOException {
new ChNarrow(hash),
this.outputPath
),
new OyRemote(hash),
new OyIndexed(new OyRemote(hash)),
this.forceUpdate()
);
}
Expand Down
3 changes: 2 additions & 1 deletion eo-maven-plugin/src/main/java/org/eolang/maven/PullMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import org.eolang.maven.objectionary.OyEmpty;
import org.eolang.maven.objectionary.OyFallbackSwap;
import org.eolang.maven.objectionary.OyHome;
import org.eolang.maven.objectionary.OyIndexed;
import org.eolang.maven.objectionary.OyRemote;
import org.eolang.maven.util.Home;
import org.eolang.maven.util.Online;
Expand Down Expand Up @@ -172,7 +173,7 @@ private static Objectionary remote(final CommitHash hash) {
Objectionary obj;
try {
InetAddress.getByName("home.objectionary.com").isReachable(1000);
obj = new OyRemote(hash);
obj = new OyIndexed(new OyRemote(hash));
} catch (final IOException ex) {
obj = new OyEmpty();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
*
* @since 0.29
*/
final class OyIndex implements Objectionary {
public final class OyIndexed implements Objectionary {

/**
* Objectionary delegate.
Expand All @@ -48,7 +48,7 @@ final class OyIndex implements Objectionary {
* Ctor.
* @param objectionary Objectionary
*/
OyIndex(final Objectionary objectionary) {
public OyIndexed(final Objectionary objectionary) {
this(objectionary, new ObjectsIndex());
}

Expand All @@ -57,7 +57,7 @@ final class OyIndex implements Objectionary {
* @param objectionary Objectionary
* @param index Index
*/
OyIndex(final Objectionary objectionary, final ObjectsIndex index) {
OyIndexed(final Objectionary objectionary, final ObjectsIndex index) {
this.delegate = objectionary;
this.index = index;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@
import org.junit.jupiter.api.extension.ExtendWith;

/**
* Test for {@link OyIndex}.
* Test for {@link OyIndexed}.
*
* @since 0.29
*/
class OyIndexTest {
class OyIndexedTest {

/**
* Object name for stdout.
Expand All @@ -48,7 +48,7 @@ class OyIndexTest {
@Test
void getsFromDelegate() throws Exception {
MatcherAssert.assertThat(
new TextOf(new OyIndex(new OyFake()).get("foo")).asString(),
new TextOf(new OyIndexed(new OyFake()).get("foo")).asString(),
Matchers.equalTo("[] > sprintf\n")
);
}
Expand All @@ -57,33 +57,33 @@ void getsFromDelegate() throws Exception {
@ExtendWith(OnlineCondition.class)
void containsInRealIndex() throws IOException {
MatcherAssert.assertThat(
new OyIndex(new OyFake()).contains(OyIndexTest.STDOUT_OBJECT),
new OyIndexed(new OyFake()).contains(OyIndexedTest.STDOUT_OBJECT),
Matchers.is(true)
);
}

@Test
void containsInFakeIndex() throws IOException {
MatcherAssert.assertThat(
new OyIndex(
new OyIndexed(
new OyFake(),
new ObjectsIndex(() -> Collections.singleton(OyIndexTest.STDOUT_OBJECT))
).contains(OyIndexTest.STDOUT_OBJECT),
new ObjectsIndex(() -> Collections.singleton(OyIndexedTest.STDOUT_OBJECT))
).contains(OyIndexedTest.STDOUT_OBJECT),
Matchers.is(true)
);
}

@Test
void checksContainsInDelegateIfExceptionHappensInIndex() throws IOException {
MatcherAssert.assertThat(
new OyIndex(
new OyIndexed(
new OyFake(),
new ObjectsIndex(
() -> {
throw new IllegalStateException("Fake exception");
}
)
).contains(OyIndexTest.STDOUT_OBJECT),
).contains(OyIndexedTest.STDOUT_OBJECT),
Matchers.is(true)
);
}
Expand Down

0 comments on commit 282f4ad

Please sign in to comment.