-
Notifications
You must be signed in to change notification settings - Fork 30
/
PlantumlPluginTest.java
63 lines (47 loc) · 1.87 KB
/
PlantumlPluginTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package io.freefair.gradle.plugins.plantuml;
import org.gradle.api.Project;
import org.gradle.api.file.DirectoryProperty;
import org.gradle.api.file.RegularFileProperty;
import org.gradle.api.provider.Property;
import org.gradle.internal.impldep.org.junit.Before;
import org.gradle.testfixtures.ProjectBuilder;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import java.io.File;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;
class PlantumlPluginTest {
private Project project;
@BeforeEach
void init() {
project = ProjectBuilder.builder().build();
}
@Test
void apply() {
project.getPlugins().apply(PlantumlPlugin.class);
assertThat(project.getTasks().getNames()).contains("plantUml");
}
@Test
void execute() {
project.getPlugins().apply(PlantumlPlugin.class);
PlantumlTask task = project.getTasks().withType(PlantumlTask.class).getByName("plantUml");
task.source(getClass().getClassLoader().getResource("puml-files").getPath());
assertThrows(UnsupportedOperationException.class, task::execute);
}
@Test
void taskExecution(@TempDir File tempDir) {
PlantumlParameters parameters = project.getObjects().newInstance(PlantumlParameters.class);
parameters.getInputFile().set(new File(getClass().getClassLoader().getResource("puml-files/test.puml").getPath()));
parameters.getOutputDirectory().set(tempDir);
parameters.getFileFormat().set("PNG");
parameters.getWithMetadata().set(false);
PlantumlAction action = new PlantumlAction() {
@Override
public PlantumlParameters getParameters() {
return parameters;
}
};
action.execute();
}
}