Skip to content

Commit

Permalink
Add test data utils tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vincent-karuri committed Feb 25, 2019
1 parent a3346c7 commit 7336065
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package io.ona.kujaku.sample;

import com.mapbox.geojson.Feature;

import org.json.JSONArray;
import org.junit.Test;

import java.util.List;

import static io.ona.kujaku.sample.utils.TestDataUtils.createFeatureJsonArray;
import static io.ona.kujaku.sample.utils.TestDataUtils.createFeatureList;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;

/**
* @author Vincent Karuri
*/
public class TestDataUtilsTest {

@Test
public void testCreateFeatureListShouldNotBeEmptyList() {
List<Feature> features = null;
try {
features = createFeatureList(5, 0, 31.03823, -1.214348, "test_property", "Point", false, new String[]{"property1", "property2", "property3"}, 0.001);
} catch (Exception e) {

}
assertNotNull(features);
assertEquals(features.size(), 5);
}

@Test
public void testCreateFeatureJsonArrayShouldNotBeEmpty() {
JSONArray features = null;
try {
features = createFeatureJsonArray(5, 31.03823, -1.214348, "test_property", new String[]{"property1", "property2", "property3"});
} catch (Exception e) {

}
assertNotNull(features);
assertEquals(features.length(), 5);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,11 @@ public static List<Feature> createFeatureList(int numFeatures, int startingIndex
double newLatitude = latitude;

int featureNumber = startingIndex;
int prevFeatureNumber = startingIndex;
int prevFeatureNumber = -1;

List<Feature> features = new ArrayList<>();
final int FEATURE_GROUP_SIZE = featureGroup.length;
while (featureNumber < numFeatures + startingIndex + 1) {
while (featureNumber < numFeatures + startingIndex) {
if (prevFeatureNumber != featureNumber) {
JSONObject feature = new JSONObject();
feature.put("id", "feature_" + UUID.randomUUID());
Expand Down

0 comments on commit 7336065

Please sign in to comment.