use of com.srotya.sidewinder.core.storage.mem.SetIndex in project sidewinder by srotya.
the class TestPersistentMeasurement method testTagEncodeDecode.
@Test
public void testTagEncodeDecode() throws IOException {
String indexDir = "target/test";
MetricsRegistryService.getInstance(engine, bgTaskPool).getInstance("requests");
MiscUtils.delete(new File(indexDir));
new File(indexDir).mkdirs();
SetIndex table = new SetIndex(indexDir, "test2");
Measurement measurement = new PersistentMeasurement();
String encodedStr = measurement.encodeTagsToString(table, Arrays.asList("host=2", "value=1", "test=1"));
List<Tag> decodedStr = Measurement.decodeStringToTags(table, encodedStr);
List<Tag> list = Arrays.asList(new Tag("host", "2"), new Tag("value", "1"), new Tag("test", "1"));
for (int i = 0; i < list.size(); i++) {
assertEquals(list.get(i) + "", list.get(i), decodedStr.get(i));
}
}