Skip to content

Commit

Permalink
#141 use cactoos'es primitives
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-semenyuk committed Jul 22, 2017
1 parent 09cdec2 commit 664943d
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
package org.eolang.compiler.java;

import java.util.Collection;
import java.util.Collections;
import org.cactoos.InputHasContent;
import org.cactoos.list.IterableAsList;
import org.cactoos.text.FormattedText;
Expand Down Expand Up @@ -55,7 +54,7 @@ public void classCode() {
MatcherAssert.assertThat(
new JavaClass(
name,
Collections.singleton(type),
new IterableAsList<>(type),
new ObjectBody(
new IterableAsList<>(),
new IterableAsList<>(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/
package org.eolang.compiler.java;

import java.util.Collections;
import org.cactoos.InputHasContent;
import org.cactoos.list.IterableAsList;
import org.cactoos.text.FormattedText;
Expand All @@ -50,7 +49,7 @@ public void interfaceCode() {
MatcherAssert.assertThat(
new JavaInterface(
name,
Collections.emptyList()
new IterableAsList<>()
).code(),
new InputHasContent(
Matchers.stringContainsInOrder(
Expand All @@ -75,7 +74,7 @@ public void interfacePath() {
MatcherAssert.assertThat(
new JavaInterface(
name,
Collections.emptyList()
new IterableAsList<>()
).path().toString(),
Matchers.equalTo(
new UncheckedText(
Expand Down
46 changes: 36 additions & 10 deletions eo-maven-plugin/src/test/java/org/eolang/maven/CompileMojoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,25 @@
package org.eolang.maven;

import java.io.File;
import java.nio.file.Files;
import org.apache.maven.plugin.testing.AbstractMojoTestCase;
import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
import org.cactoos.io.BytesAsInput;
import org.cactoos.io.FileAsOutput;
import org.cactoos.io.LengthOfInput;
import org.cactoos.io.TeeInput;
import org.cactoos.text.StringAsText;
import org.cactoos.text.TextAsBytes;
import org.eolang.compiler.CompileException;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.rules.TemporaryFolder;

/**
* Test case for {@link Main}.
* Test case for {@link CompileMojo}.
* @author Yegor Bugayenko (yegor256@gmail.com)
* @version $Id$
* @since 0.1
* @checkstyle ClassDataAbstractionCouplingCheck (500 lines)
*/
@SuppressWarnings("PMD.AvoidDuplicateLiterals")
public final class CompileMojoTest extends AbstractMojoTestCase {
Expand All @@ -56,10 +62,20 @@ public void testSimpleCompilation() throws Exception {
this.temp.create();
final File src = this.temp.newFolder();
this.setVariableValueToObject(mojo, "sourceDirectory", src);
Files.write(
new File(src, "main.eo").toPath(),
"type Pixel:\n Pixel moveTo(Integer x, Integer y)".getBytes()
);
new LengthOfInput(
new TeeInput(
new BytesAsInput(
new TextAsBytes(
new StringAsText(
"type Pixel:\n Pixel moveTo(Integer x, Integer y)"
)
)
),
new FileAsOutput(
new File(src, "main.eo")
)
)
).value();
final File target = this.temp.newFolder();
this.setVariableValueToObject(mojo, "targetDirectory", target);
this.setVariableValueToObject(mojo, "project", new MavenProjectStub());
Expand All @@ -82,10 +98,20 @@ public void testCrashOnInvalidSyntax() throws Exception {
this.setVariableValueToObject(
mojo, "targetDirectory", this.temp.newFolder()
);
Files.write(
new File(src, "f.eo").toPath(),
"something is wrong here".getBytes()
);
new LengthOfInput(
new TeeInput(
new BytesAsInput(
new TextAsBytes(
new StringAsText(
"something is wrong here"
)
)
),
new FileAsOutput(
new File(src, "f.eo")
)
)
).value();
try {
mojo.execute();
throw new IllegalArgumentException("exception is not here, why?");
Expand Down

0 comments on commit 664943d

Please sign in to comment.