Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored API of AvroUtils and added unit test on them
- Loading branch information
Showing
6 changed files
with
90 additions
and
8 deletions.
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
37 changes: 37 additions & 0 deletions
37
...on/core/src/test/java/org/kaaproject/kaa/server/common/core/algorithms/AvroUtilsTest.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,37 @@ | ||
package org.kaaproject.kaa.server.common.core.algorithms; | ||
|
||
|
||
import org.codehaus.jackson.JsonNode; | ||
import org.codehaus.jackson.map.ObjectMapper; | ||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import java.io.IOException; | ||
|
||
public class AvroUtilsTest { | ||
private JsonNode data; | ||
private JsonNode dataWithUUIDs; | ||
|
||
@Before | ||
public void setUp() throws IOException { | ||
data = new ObjectMapper().readTree(AvroUtilsTest.class.getClassLoader().getResourceAsStream("uuids/data.json")); | ||
dataWithUUIDs = new ObjectMapper().readTree(AvroUtilsTest.class.getClassLoader().getResourceAsStream("uuids/data_with_uuids.json")); | ||
} | ||
|
||
@Test | ||
public void testInjectUuids() throws IOException { | ||
AvroUtils.injectUuids(data); | ||
String jsonWithUUIds = data.toString(); | ||
Assert.assertTrue("Generated json is not equal json with UUIDs", jsonWithUUIds.equals(dataWithUUIDs.toString())); | ||
} | ||
|
||
|
||
@Test | ||
public void testRemoveUuids() throws IOException { | ||
AvroUtils.removeUuids(dataWithUUIDs); | ||
String json = dataWithUUIDs.toString(); | ||
Assert.assertTrue("Generated json is not equal json without UUIDs", json.equals(data.toString())); | ||
} | ||
|
||
} |
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,22 @@ | ||
{ | ||
"AddressList": { | ||
"array": [ | ||
{ | ||
"label": "Kaa website", | ||
"url": "http://www.kaaproject.org" | ||
}, | ||
{ | ||
"label": "Kaa GitHub repository", | ||
"url": "https://github.com/kaaproject/kaa" | ||
}, | ||
{ | ||
"label": "Kaa docs", | ||
"url": "http://docs.kaaproject.org/display/KAA/Kaa+IoT+Platform+Home" | ||
}, | ||
{ | ||
"label": "Kaa configuration design reference", | ||
"url": "http://docs.kaaproject.org/display/KAA/Configuration" | ||
} | ||
] | ||
} | ||
} |
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,27 @@ | ||
{ | ||
"AddressList": { | ||
"array": [ | ||
{ | ||
"label": "Kaa website", | ||
"url": "http://www.kaaproject.org", | ||
"__uuid":null | ||
}, | ||
{ | ||
"label": "Kaa GitHub repository", | ||
"url": "https://github.com/kaaproject/kaa", | ||
"__uuid":null | ||
}, | ||
{ | ||
"label": "Kaa docs", | ||
"url": "http://docs.kaaproject.org/display/KAA/Kaa+IoT+Platform+Home", | ||
"__uuid":null | ||
}, | ||
{ | ||
"label": "Kaa configuration design reference", | ||
"url": "http://docs.kaaproject.org/display/KAA/Configuration", | ||
"__uuid":null | ||
} | ||
] | ||
}, | ||
"__uuid":null | ||
} |
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
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