mirror of
https://github.com/itplr-kosit/validator.git
synced 2026-05-25 16:55:39 +00:00
(chore) reduce test objects, reuse simple stuff
This commit is contained in:
parent
d7f4a78fbc
commit
515b45bc6e
2 changed files with 24 additions and 25 deletions
|
|
@ -22,7 +22,6 @@ package de.kosit.validationtool.cmd;
|
|||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.stream.Collectors;
|
||||
|
|
@ -34,6 +33,7 @@ import org.junit.Test;
|
|||
|
||||
import de.kosit.validationtool.api.InputFactory;
|
||||
import de.kosit.validationtool.impl.Helper;
|
||||
import de.kosit.validationtool.impl.Helper.Simple;
|
||||
import de.kosit.validationtool.impl.tasks.CheckAction;
|
||||
|
||||
/**
|
||||
|
|
@ -43,7 +43,6 @@ import de.kosit.validationtool.impl.tasks.CheckAction;
|
|||
*/
|
||||
public class ExtractHtmlActionTest {
|
||||
|
||||
private static final URL REPORT = SerializeReportActionTest.class.getResource("/examples/results/report.xml");
|
||||
|
||||
private ExtractHtmlContentAction action;
|
||||
|
||||
|
|
@ -51,24 +50,24 @@ public class ExtractHtmlActionTest {
|
|||
|
||||
@Before
|
||||
public void setup() throws IOException {
|
||||
tmpDirectory = Files.createTempDirectory("checktool");
|
||||
action = new ExtractHtmlContentAction(Helper.loadTestRepository(), tmpDirectory);
|
||||
this.tmpDirectory = Files.createTempDirectory("checktool");
|
||||
this.action = new ExtractHtmlContentAction(Helper.loadTestRepository(), this.tmpDirectory);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws IOException {
|
||||
FileUtils.deleteDirectory(tmpDirectory.toFile());
|
||||
FileUtils.deleteDirectory(this.tmpDirectory.toFile());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimple() throws IOException {
|
||||
CheckAction.Bag b = new CheckAction.Bag(InputFactory.read(REPORT));
|
||||
assertThat(action.isSkipped(b)).isTrue();
|
||||
b.setReport(Helper.load(REPORT));
|
||||
action.check(b);
|
||||
assertThat(action.isSkipped(b)).isFalse();
|
||||
action.check(b);
|
||||
final CheckAction.Bag b = new CheckAction.Bag(InputFactory.read(Simple.SIMPLE_VALID));
|
||||
assertThat(this.action.isSkipped(b)).isTrue();
|
||||
b.setReport(Helper.load(Simple.SIMPLE_VALID.toURL()));
|
||||
this.action.check(b);
|
||||
assertThat(this.action.isSkipped(b)).isFalse();
|
||||
this.action.check(b);
|
||||
assertThat(b.isStopped()).isFalse();
|
||||
assertThat(Files.list(tmpDirectory).collect(Collectors.toList())).hasSize(1);
|
||||
assertThat(Files.list(this.tmpDirectory).collect(Collectors.toList())).hasSize(1);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ package de.kosit.validationtool.cmd;
|
|||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.net.MalformedURLException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
|
|
@ -33,6 +33,7 @@ import org.junit.Test;
|
|||
|
||||
import de.kosit.validationtool.api.InputFactory;
|
||||
import de.kosit.validationtool.impl.Helper;
|
||||
import de.kosit.validationtool.impl.Helper.Simple;
|
||||
import de.kosit.validationtool.impl.tasks.CheckAction;
|
||||
|
||||
/**
|
||||
|
|
@ -40,7 +41,6 @@ import de.kosit.validationtool.impl.tasks.CheckAction;
|
|||
*/
|
||||
public class SerializeReportActionTest {
|
||||
|
||||
private static final URL REPORT = SerializeReportActionTest.class.getResource("/examples/results/report.xml");
|
||||
|
||||
private Path tmpDirectory;
|
||||
|
||||
|
|
@ -48,31 +48,31 @@ public class SerializeReportActionTest {
|
|||
|
||||
@Before
|
||||
public void setup() throws IOException {
|
||||
tmpDirectory = Files.createTempDirectory("checktool");
|
||||
action = new SerializeReportAction(tmpDirectory);
|
||||
this.tmpDirectory = Files.createTempDirectory("checktool");
|
||||
this.action = new SerializeReportAction(this.tmpDirectory);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws IOException {
|
||||
FileUtils.deleteDirectory(tmpDirectory.toFile());
|
||||
FileUtils.deleteDirectory(this.tmpDirectory.toFile());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimpleSerialize() {
|
||||
CheckAction.Bag b = new CheckAction.Bag(InputFactory.read(REPORT));
|
||||
assertThat(action.isSkipped(b)).isTrue();
|
||||
b.setReport(Helper.load(REPORT));
|
||||
assertThat(action.isSkipped(b)).isFalse();
|
||||
action.check(b);
|
||||
public void testSimpleSerialize() throws MalformedURLException {
|
||||
final CheckAction.Bag b = new CheckAction.Bag(InputFactory.read(Simple.SIMPLE_VALID));
|
||||
assertThat(this.action.isSkipped(b)).isTrue();
|
||||
b.setReport(Helper.load(Simple.SIMPLE_VALID.toURL()));
|
||||
assertThat(this.action.isSkipped(b)).isFalse();
|
||||
this.action.check(b);
|
||||
assertThat(b.isStopped()).isFalse();
|
||||
assertThat(tmpDirectory.toFile().listFiles()).hasSize(1);
|
||||
assertThat(this.tmpDirectory.toFile().listFiles()).hasSize(1);
|
||||
}
|
||||
|
||||
//ERPT-83
|
||||
@Test
|
||||
public void testName(){
|
||||
final String name = "some.name.with.dots";
|
||||
CheckAction.Bag b = new CheckAction.Bag(InputFactory.read("ega".getBytes(), name + ".xml"));
|
||||
final CheckAction.Bag b = new CheckAction.Bag(InputFactory.read("ega".getBytes(), name + ".xml"));
|
||||
assertThat(b.getName()).isEqualTo(name);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue