21
21
import static org .assertj .core .api .Assertions .assertThat ;
22
22
23
23
import com .orientechnologies .common .io .OFileUtils ;
24
- import com .orientechnologies .orient .etl .loader .OETLOrientDBLoader ;
25
24
import com .orientechnologies .orient .etl .transformer .OETLVertexTransformer ;
26
25
import java .io .File ;
27
26
import org .junit .Before ;
30
29
/** Created by frank on 9/18/15. */
31
30
public class OETLProcessorTest extends OETLBaseTest {
32
31
33
- private static final String databaseDir = "./target/databases/" ;
32
+ private static final String databaseDir = "./target/databases/etlProcessor " ;
34
33
35
34
@ Before
36
35
public void setUp () throws Exception {
@@ -40,63 +39,53 @@ public void setUp() throws Exception {
40
39
@ Test
41
40
public void testMain () throws Exception {
42
41
43
- final OETLProcessor processor =
42
+ try ( OETLProcessor processor =
44
43
new OETLProcessorConfigurator ()
45
44
.parseConfigAndParameters (
46
45
new String [] {
47
46
"-dbURL=plocal:" + databaseDir + "orientDBoetl/testMain" ,
48
47
"./src/test/resources/comment.json"
49
- });
48
+ })) {
50
49
51
- assertThat (processor .getContext ().getVariable ("dbURL" ))
52
- .isEqualTo ("plocal:" + databaseDir + "orientDBoetl/testMain" );
53
-
54
- OETLOrientDBLoader loader = (OETLOrientDBLoader ) processor .getLoader ();
55
- loader .getPool ().close ();
56
-
57
- loader .orient .close ();
50
+ assertThat (processor .getContext ().getVariable ("dbURL" ))
51
+ .isEqualTo ("plocal:" + databaseDir + "orientDBoetl/testMain" );
52
+ }
58
53
}
59
54
60
55
@ Test
61
56
public void shouldParseSplitConfiguration () throws Exception {
62
57
63
- final OETLProcessor processor =
58
+ try ( OETLProcessor processor =
64
59
new OETLProcessorConfigurator ()
65
60
.parseConfigAndParameters (
66
61
new String [] {
67
62
"-dbURL=plocal:" + databaseDir + "orientDBoetl/shouldParseSplitConfiguration" ,
68
63
"./src/test/resources/comment_split_1.json" ,
69
64
"./src/test/resources/comment_split_2.json"
70
- });
65
+ })) {
71
66
72
- assertThat (processor .getContext ().getVariable ("dbURL" ))
73
- .isEqualTo ("plocal:" + databaseDir + "orientDBoetl/shouldParseSplitConfiguration" );
74
- assertThat (processor .getTransformers ().get (0 )).isInstanceOf (OETLVertexTransformer .class );
75
- assertThat (processor .getExtractor ().getName ()).isEqualTo ("csv" );
76
- OETLOrientDBLoader loader = (OETLOrientDBLoader ) processor .getLoader ();
77
- loader .getPool ().close ();
78
-
79
- loader .orient .close ();
67
+ assertThat (processor .getContext ().getVariable ("dbURL" ))
68
+ .isEqualTo ("plocal:" + databaseDir + "orientDBoetl/shouldParseSplitConfiguration" );
69
+ assertThat (processor .getTransformers ().get (0 )).isInstanceOf (OETLVertexTransformer .class );
70
+ assertThat (processor .getExtractor ().getName ()).isEqualTo ("csv" );
71
+ }
80
72
}
81
73
82
74
@ Test
83
75
public void shouldExceuteBeginBlocktoExpandVariables () throws Exception {
84
76
85
- final OETLProcessor processor =
77
+ try ( OETLProcessor processor =
86
78
new OETLProcessorConfigurator ()
87
79
.parseConfigAndParameters (
88
80
new String [] {
89
81
"-dbURL=plocal:"
90
82
+ databaseDir
91
83
+ "orientDBoetl/shouldExceuteBeginBlocktoExpandVariables" ,
92
84
"./src/test/resources/comment.json"
93
- });
94
-
95
- assertThat (processor .context .getVariable ("filePath" ))
96
- .isEqualTo ("./src/test/resources/comments.csv" );
97
- OETLOrientDBLoader loader = (OETLOrientDBLoader ) processor .getLoader ();
98
- loader .getPool ().close ();
85
+ })) {
99
86
100
- loader .orient .close ();
87
+ assertThat (processor .context .getVariable ("filePath" ))
88
+ .isEqualTo ("./src/test/resources/comments.csv" );
89
+ }
101
90
}
102
91
}
0 commit comments