1
|
package eu.dnetlib.maven.plugin.properties;
|
2
|
|
3
|
import static eu.dnetlib.maven.plugin.properties.GenerateOoziePropertiesMojo.PROPERTY_NAME_SANDBOX_NAME;
|
4
|
import static eu.dnetlib.maven.plugin.properties.GenerateOoziePropertiesMojo.PROPERTY_NAME_WF_SOURCE_DIR;
|
5
|
import static org.junit.Assert.assertEquals;
|
6
|
import static org.junit.Assert.assertNull;
|
7
|
|
8
|
import org.junit.Before;
|
9
|
import org.junit.Test;
|
10
|
|
11
|
/**
|
12
|
* @author mhorst
|
13
|
*
|
14
|
*/
|
15
|
public class GenerateOoziePropertiesMojoTest {
|
16
|
|
17
|
private GenerateOoziePropertiesMojo mojo = new GenerateOoziePropertiesMojo();
|
18
|
|
19
|
@Before
|
20
|
public void clearSystemProperties() {
|
21
|
System.clearProperty(PROPERTY_NAME_SANDBOX_NAME);
|
22
|
System.clearProperty(PROPERTY_NAME_WF_SOURCE_DIR);
|
23
|
}
|
24
|
|
25
|
@Test
|
26
|
public void testExecuteEmpty() throws Exception {
|
27
|
// execute
|
28
|
mojo.execute();
|
29
|
|
30
|
// assert
|
31
|
assertNull(System.getProperty(PROPERTY_NAME_SANDBOX_NAME));
|
32
|
}
|
33
|
|
34
|
@Test
|
35
|
public void testExecuteSandboxNameAlreadySet() throws Exception {
|
36
|
// given
|
37
|
String workflowSourceDir = "eu/dnetlib/iis/wf/transformers";
|
38
|
String sandboxName = "originalSandboxName";
|
39
|
System.setProperty(PROPERTY_NAME_WF_SOURCE_DIR, workflowSourceDir);
|
40
|
System.setProperty(PROPERTY_NAME_SANDBOX_NAME, sandboxName);
|
41
|
|
42
|
// execute
|
43
|
mojo.execute();
|
44
|
|
45
|
// assert
|
46
|
assertEquals(sandboxName, System.getProperty(PROPERTY_NAME_SANDBOX_NAME));
|
47
|
}
|
48
|
|
49
|
@Test
|
50
|
public void testExecuteEmptyWorkflowSourceDir() throws Exception {
|
51
|
// given
|
52
|
String workflowSourceDir = "";
|
53
|
System.setProperty(PROPERTY_NAME_WF_SOURCE_DIR, workflowSourceDir);
|
54
|
|
55
|
// execute
|
56
|
mojo.execute();
|
57
|
|
58
|
// assert
|
59
|
assertNull(System.getProperty(PROPERTY_NAME_SANDBOX_NAME));
|
60
|
}
|
61
|
|
62
|
@Test
|
63
|
public void testExecuteNullSandboxNameGenerated() throws Exception {
|
64
|
// given
|
65
|
String workflowSourceDir = "eu/dnetlib/iis/";
|
66
|
System.setProperty(PROPERTY_NAME_WF_SOURCE_DIR, workflowSourceDir);
|
67
|
|
68
|
// execute
|
69
|
mojo.execute();
|
70
|
|
71
|
// assert
|
72
|
assertNull(System.getProperty(PROPERTY_NAME_SANDBOX_NAME));
|
73
|
}
|
74
|
|
75
|
@Test
|
76
|
public void testExecute() throws Exception {
|
77
|
// given
|
78
|
String workflowSourceDir = "eu/dnetlib/iis/wf/transformers";
|
79
|
System.setProperty(PROPERTY_NAME_WF_SOURCE_DIR, workflowSourceDir);
|
80
|
|
81
|
// execute
|
82
|
mojo.execute();
|
83
|
|
84
|
// assert
|
85
|
assertEquals("wf/transformers", System.getProperty(PROPERTY_NAME_SANDBOX_NAME));
|
86
|
}
|
87
|
|
88
|
@Test
|
89
|
public void testExecuteWithoutRoot() throws Exception {
|
90
|
// given
|
91
|
String workflowSourceDir = "wf/transformers";
|
92
|
System.setProperty(PROPERTY_NAME_WF_SOURCE_DIR, workflowSourceDir);
|
93
|
|
94
|
// execute
|
95
|
mojo.execute();
|
96
|
|
97
|
// assert
|
98
|
assertEquals("wf/transformers", System.getProperty(PROPERTY_NAME_SANDBOX_NAME));
|
99
|
}
|
100
|
|
101
|
}
|