Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1343 - replacing static MatcherAssert.assertThat with Assertion object #1344

Merged
merged 5 commits into from
Apr 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 28 additions & 19 deletions src/test/java/org/cactoos/io/TeeInputFromCharArrayTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import org.hamcrest.MatcherAssert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.llorllale.cactoos.matchers.Assertion;
import org.llorllale.cactoos.matchers.InputHasContent;

/**
Expand All @@ -52,14 +52,15 @@ public void copiesFromCharArrayWithCharsetToFile() throws IOException {
final String input =
"Hello, товарищ file #1 äÄ üÜ öÖ and ß";
final File output = this.folder.newFile();
MatcherAssert.assertThat(
new Assertion<>(
Copy link
Collaborator

@victornoel victornoel Apr 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lxpdd you need to call affirm() on all the Assertion objects for the assertion to be verified. Currently those tests do nothing.

Copy link
Collaborator

@victornoel victornoel Apr 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lxpdd you are missing affirm() on this one

"char array must be copied to the file with charset UTF_8",
new TeeInput(
input.toCharArray(),
output,
StandardCharsets.UTF_8
),
new InputHasContent(input)
);
).affirm();
}

@Test
Expand All @@ -68,43 +69,46 @@ public void copiesFromCharArrayWithCharsetByNameToFile()
final String input =
"Hello, товарищ file #2 äÄ üÜ öÖ and ß";
final File output = this.folder.newFile();
MatcherAssert.assertThat(
new Assertion<>(
"char array must be copied to the file with UTF_8 charset's name",
new TeeInput(
input.toCharArray(),
output,
StandardCharsets.UTF_8.name()
),
new InputHasContent(input)
);
).affirm();
}

@Test
public void copiesFromCharArrayToOutput() throws IOException {
final String input =
"Hello, товарищ output #1 äÄ üÜ öÖ and ß";
final File output = this.folder.newFile();
MatcherAssert.assertThat(
new Assertion<>(
"char array must be copied to the output",
new TeeInput(
input.toCharArray(),
new OutputTo(output)
),
new InputHasContent(input)
);
).affirm();
}

@Test
public void copiesFromCharArrayWithCharsetToOutput() throws IOException {
final String input =
"Hello, товарищ output #2 äÄ üÜ öÖ and ß";
final File output = this.folder.newFile();
MatcherAssert.assertThat(
new Assertion<>(
"char array must be copied to the output with UTF_8 charset",
new TeeInput(
input.toCharArray(),
new OutputTo(output),
StandardCharsets.UTF_8
),
new InputHasContent(input)
);
).affirm();
}

@Test
Expand All @@ -113,43 +117,46 @@ public void copiesFromCharArrayWithCharsetByNameToOutput()
final String input =
"Hello, товарищ output #3 äÄ üÜ öÖ and ß";
final File output = this.folder.newFile();
MatcherAssert.assertThat(
new Assertion<>(
"char array must be copied to the output with UTF_8 charset's name",
new TeeInput(
input.toCharArray(),
new OutputTo(output),
StandardCharsets.UTF_8.name()
),
new InputHasContent(input)
);
).affirm();
}

@Test
public void copiesFromCharArrayToPath() throws IOException {
final String input =
"Hello, товарищ path #1 äÄ üÜ öÖ and ß";
final File output = this.folder.newFile();
MatcherAssert.assertThat(
new Assertion<>(
"char array must be copied to the path",
new TeeInput(
input.toCharArray(),
output.toPath()
),
new InputHasContent(input)
);
).affirm();
}

@Test
public void copiesFromCharArrayWithCharsetToPath() throws IOException {
final String input =
"Hello, товарищ path #2 äÄ üÜ öÖ and ß";
final File output = this.folder.newFile();
MatcherAssert.assertThat(
new Assertion<>(
"char array must be copied to the path with UTF_8 charset",
new TeeInput(
input.toCharArray(),
output.toPath(),
StandardCharsets.UTF_8
),
new InputHasContent(input)
);
).affirm();
}

@Test
Expand All @@ -158,27 +165,29 @@ public void copiesFromCharArrayWithCharsetByNameToPath()
final String input =
"Hello, товарищ path #3 äÄ üÜ öÖ and ß";
final File output = this.folder.newFile();
MatcherAssert.assertThat(
new Assertion<>(
"char array must be copied to the path with UTF_8 charset's name",
new TeeInput(
input.toCharArray(),
output.toPath(),
StandardCharsets.UTF_8.name()
),
new InputHasContent(input)
);
).affirm();
}

@Test
public void copiesFromCharArrayToFile() throws IOException {
final File output = this.folder.newFile();
final String input =
"Hello, товарищ file äÄ üÜ öÖ and ß";
MatcherAssert.assertThat(
new Assertion<>(
"char array must be copied to the file",
new TeeInput(
input.toCharArray(),
output
),
new InputHasContent(input)
);
).affirm();
}
}
49 changes: 29 additions & 20 deletions src/test/java/org/cactoos/io/TeeInputFromCharSequenceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import org.hamcrest.MatcherAssert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.llorllale.cactoos.matchers.Assertion;
import org.llorllale.cactoos.matchers.InputHasContent;

/**
Expand All @@ -52,28 +52,30 @@ public void copiesFromCharSequenceToFile() throws IOException {
final String input =
"Hello, товарищ file #1 äÄ üÜ öÖ and ß";
final File output = this.folder.newFile();
MatcherAssert.assertThat(
new Assertion<>(
"char sequence must be copied to the file",
new TeeInput(
input,
output
),
new InputHasContent(input)
);
).affirm();
}

@Test
public void copiesFromCharSequenceWithCharsetToFile() throws IOException {
final String input =
"Hello, товарищ file #2 äÄ üÜ öÖ and ß";
final File output = this.folder.newFile();
MatcherAssert.assertThat(
new Assertion<>(
"char sequence must be copied to the file with UTF_8 charset",
new TeeInput(
input,
output,
StandardCharsets.UTF_8
),
new InputHasContent(input)
);
).affirm();
}

@Test
Expand All @@ -82,43 +84,46 @@ public void copiesFromCharSequenceWithCharsetByNameToFile()
final String input =
"Hello, товарищ file #3 äÄ üÜ öÖ and ß";
final File output = this.folder.newFile();
MatcherAssert.assertThat(
new Assertion<>(
"char sequence must be copied to the file with UTF_8 charset's name",
new TeeInput(
input,
output,
StandardCharsets.UTF_8.name()
),
new InputHasContent(input)
);
).affirm();
}

@Test
public void copiesFromCharSequenceToPath() throws IOException {
final String input =
"Hello, товарищ path #1 äÄ üÜ öÖ and ß";
final File output = this.folder.newFile();
MatcherAssert.assertThat(
new Assertion<>(
"char sequence must be copied to the path",
new TeeInput(
input,
output
output.toPath()
),
new InputHasContent(input)
);
).affirm();
}

@Test
public void copiesFromCharSequenceWithCharsetToPath() throws IOException {
final String input =
"Hello, товарищ path #2 äÄ üÜ öÖ and ß";
final File output = this.folder.newFile();
MatcherAssert.assertThat(
new Assertion<>(
"char sequence must be copied to the path with UTF_8 charset",
new TeeInput(
input,
output.toPath(),
StandardCharsets.UTF_8
),
new InputHasContent(input)
);
).affirm();
}

@Test
Expand All @@ -127,43 +132,46 @@ public void copiesFromCharSequenceWithCharsetByNameToPath()
final String input =
"Hello, товарищ path #3 äÄ üÜ öÖ and ß";
final File output = this.folder.newFile();
MatcherAssert.assertThat(
new Assertion<>(
"char sequence must be copied to the path with UTF_8 charset's name",
new TeeInput(
input,
output.toPath(),
StandardCharsets.UTF_8.name()
),
new InputHasContent(input)
);
).affirm();
}

@Test
public void copiesFromCharSequenceToOutput() throws IOException {
final String input =
"Hello, товарищ output #1 äÄ üÜ öÖ and ß";
final File output = this.folder.newFile();
MatcherAssert.assertThat(
new Assertion<>(
"char sequence must be copied to the output",
new TeeInput(
input,
new OutputTo(output)
),
new InputHasContent(input)
);
).affirm();
}

@Test
public void copiesFromCharSequenceWithCharsetToOutput() throws IOException {
final String input =
"Hello, товарищ output #2 äÄ üÜ öÖ and ß";
final File output = this.folder.newFile();
MatcherAssert.assertThat(
new Assertion<>(
"char sequence must be copied to the output with UTF_8 charset",
new TeeInput(
input,
new OutputTo(output),
StandardCharsets.UTF_8
),
new InputHasContent(input)
);
).affirm();
}

@Test
Expand All @@ -172,13 +180,14 @@ public void copiesFromCharSequenceWithCharsetByNameToOutput()
final String input =
"Hello, товарищ output #3 äÄ üÜ öÖ and ß";
final File output = this.folder.newFile();
MatcherAssert.assertThat(
new Assertion<>(
"char sequence must be copied to the output with UTF_8 charset's name",
new TeeInput(
input,
new OutputTo(output),
StandardCharsets.UTF_8.name()
),
new InputHasContent(input)
);
).affirm();
}
}
Loading