Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
import org.junit.Test;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Properties;

import static org.apache.zeppelin.iotdb.IoTDBInterpreter.DEFAULT_ENABLE_RPC_COMPRESSION;
Expand Down Expand Up @@ -324,7 +328,7 @@ public void testShowTimeseries() {
+ "root.test.wf01.wt01.hardware\tnull\troot.test.wf01\tFLOAT\tGORILLA\tSNAPPY\tnull\tnull";
Assert.assertNotNull(actual);
Assert.assertEquals(Code.SUCCESS, actual.code());
Assert.assertEquals(gt, actual.message().get(0).getData());
assertEqualsNonStrict(gt, actual.message().get(0).getData());
}

@Test
Expand All @@ -334,7 +338,7 @@ public void testShowDevices() {
"devices\tisAligned\n" + "root.test.wf02.wt02\tfalse\n" + "root.test.wf01.wt01\tfalse";
Assert.assertNotNull(actual);
Assert.assertEquals(Code.SUCCESS, actual.code());
Assert.assertEquals(gt, actual.message().get(0).getData());
assertEqualsNonStrict(gt, actual.message().get(0).getData());
}

@Test
Expand All @@ -348,7 +352,7 @@ public void testShowDevicesWithSg() {
Assert.assertNotNull(actual);
Assert.assertEquals(Code.SUCCESS, actual.code());
System.out.println(actual.message().get(0).getData());
Assert.assertEquals(gt, actual.message().get(0).getData());
assertEqualsNonStrict(gt, actual.message().get(0).getData());
}

@Test
Expand All @@ -358,7 +362,7 @@ public void testShowAllTTL() {
String gt = "storage group\tttl\n" + "root.test.wf02\tnull\n" + "root.test.wf01\t12345";
Assert.assertNotNull(actual);
Assert.assertEquals(Code.SUCCESS, actual.code());
Assert.assertEquals(gt, actual.message().get(0).getData());
assertEqualsNonStrict(gt, actual.message().get(0).getData());
}

@Test
Expand All @@ -377,7 +381,7 @@ public void testShowStorageGroup() {
String gt = "storage group\n" + "root.test.wf02\n" + "root.test.wf01";
Assert.assertNotNull(actual);
Assert.assertEquals(Code.SUCCESS, actual.code());
Assert.assertEquals(gt, actual.message().get(0).getData());
assertEqualsNonStrict(gt, actual.message().get(0).getData());
}

@Test
Expand All @@ -389,4 +393,11 @@ public void testListUser() {
Assert.assertEquals(Code.SUCCESS, actual.code());
Assert.assertEquals(gt, actual.message().get(0).getData());
}

private void assertEqualsNonStrict(String gt, String actual) {
List<String> actualList = new ArrayList<String>(Arrays.asList(actual.split("\n")));
List<String> expectedList = new ArrayList<String>(Arrays.asList(gt.split("\n")));
Assert.assertEquals(expectedList.get(0), actualList.get(0));
Assert.assertEquals(new HashSet<String>(expectedList), new HashSet<String>(actualList));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This modification has a benifit that we can know which line of results are incorrect.
However, IMO, it is sensitive about the order of the resultset table.
So, using Hashset to compare the result is not very good.
We may need to use ArrayList to split the result and compare them line by line.

}
}