-
Notifications
You must be signed in to change notification settings - Fork 872
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 from profeg/OLogTransformerTest
O log transformer test
- Loading branch information
Showing
2 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/test/java/com/orientechnologies/orient/etl/transformer/OLogTransformerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.orientechnologies.orient.etl.transformer; | ||
|
||
import com.orientechnologies.orient.core.record.impl.ODocument; | ||
import com.orientechnologies.orient.etl.ETLBaseTest; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import java.io.ByteArrayOutputStream; | ||
import java.io.PrintStream; | ||
import java.util.List; | ||
|
||
import static org.junit.Assert.*; | ||
import static org.junit.Assert.assertEquals; | ||
|
||
public class OLogTransformerTest extends ETLBaseTest { | ||
|
||
private final PrintStream OUT = System.out; | ||
|
||
@Test | ||
public void testPrefix() throws Exception { | ||
ByteArrayOutputStream output = getByteArrayOutputStream(); | ||
String cfgJson = "{source: { content: { value: 'id,text\n1,Hello\n2,Bye'} }, extractor : { row : {} }, transformers : [{ csv : {} },{ log : {prefix:'-> '}}], loader : { test: {} } }"; | ||
process(cfgJson); | ||
List<ODocument> res = getResult(); | ||
ODocument doc = res.get(0); | ||
String[] stringList = output.toString().split("\n"); | ||
assertEquals("[1:log] INFO -> {id:1,text:Hello}", stringList[1]); | ||
assertEquals("[2:log] INFO -> {id:2,text:Bye}", stringList[2]); | ||
} | ||
@Test | ||
public void testPostfix() throws Exception { | ||
ByteArrayOutputStream output = getByteArrayOutputStream(); | ||
String cfgJson = "{source: { content: { value: 'id,text\n1,Hello\n2,Bye'} }, extractor : { row : {} }, transformers : [{ csv : {} },{ log : {postfix:'-> '}}], loader : { test: {} } }"; | ||
process(cfgJson); | ||
List<ODocument> res = getResult(); | ||
ODocument doc = res.get(0); | ||
String[] stringList = output.toString().split("\n"); | ||
assertEquals("[1:log] INFO {id:1,text:Hello}-> ", stringList[1]); | ||
assertEquals("[2:log] INFO {id:2,text:Bye}-> ", stringList[2]); | ||
} | ||
|
||
private ByteArrayOutputStream getByteArrayOutputStream() { | ||
ByteArrayOutputStream output = new ByteArrayOutputStream(); | ||
System.setOut(new PrintStream(output, true)); | ||
return output; | ||
} | ||
|
||
} |