Skip to content
Open
Show file tree
Hide file tree
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
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,18 @@ If you’re new to ODK-X you can check out the documentation:
Once you’re up and running, you can choose an issue to start working on from here: 
- [https://github.com/odk-x/tool-suite-X/issues](https://github.com/odk-x/tool-suite-X/issues)

If you're writing tests, we use JaCoCo for test coverage reporting. This is already included in [gradle-config](https://github.com/odk-x/gradle-config)

Issues tagged as [good first issue](https://github.com/odk-x/tool-suite-X/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22) should be a good place to start.

Pull requests are welcome, though please submit them against the development branch. We prefer verbose descriptions of the change you are submitting. If you are fixing a bug please provide steps to reproduce it or a link to a an issue that provides that information. If you are submitting a new feature please provide a description of the need or a link to a forum discussion about it.

## Running and viewing test coverage
- Ensure you have a successful Build.
- For Unit Test: Run coverage with `./gradlew createSnapshotDebugUnitTestCoverageReport`.
- For Android Test: Run coverage with `./gradlew createSnapshotDebugAndroidTestCoverageReport`.
- To view unit test report, open the file at ( .../androidlibrary_lib/build/reports/coverage/test/snapshot/debug/index.html) in browser.
- To view android test report, open the file at ( .../androidlibrary_lib/build/reports/androidTests/connected/debug/flavors/snapshot/index.html) in browser.

## Links for users
This document is aimed at helping developers and technical contributors. For information on how to get started as a user of ODK-X, see our [online documentation](https://docs.odk-x.org), or to learn more about the Open Data Kit project, visit [https://odk-x.org](https://odk-x.org).
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

import android.graphics.Color;

import androidx.annotation.NonNull;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert;
Expand All @@ -30,6 +32,7 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.util.TreeMap;
import org.opendatakit.aggregate.odktables.rest.ElementDataType;
import org.opendatakit.aggregate.odktables.rest.entity.Column;
import org.opendatakit.database.data.BaseTable;
Expand All @@ -43,7 +46,6 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.TreeMap;
import java.util.UUID;

@RunWith(JUnit4.class)
Expand Down Expand Up @@ -84,7 +86,20 @@ public void setupColorRule(){
public void tearDownColorRule(){
cr = null;
}


@Test
public void testGetJsonRepresentation() {
ColorRule cr = new ColorRule("myElement", ColorRule.RuleType.EQUAL, "5", 0, 0);
TreeMap<String, Object> jsonMap = cr.getJsonRepresentation();

Assert.assertEquals("5", jsonMap.get("mValue"));
Assert.assertEquals("myElement", jsonMap.get("mElementKey"));
Assert.assertEquals(ColorRule.RuleType.EQUAL.name(), jsonMap.get("mOperator"));
Assert.assertNotNull(jsonMap.get("mId"));
Assert.assertEquals(0, jsonMap.get("mForeground"));
Assert.assertEquals(0, jsonMap.get("mBackground"));
}

@Test
public void testColorRule() {
ColorRule cr1 = new ColorRule(MY_ELEMENT, ColorRule.RuleType.EQUAL, "5", Color.BLUE, Color
Expand Down Expand Up @@ -301,6 +316,20 @@ public void givenInValidColorRuleInTableRow_whenRowSearched_thenThrowException()

private TypedRow setupTableWithRowEntriesAndReturnTypedRow(String[] rowEntries){
//Setup Color table
BaseTable table = getBaseTable();
//Define the table's column
List<Column> columns = new ArrayList<>();
columns.add(new Column(COLOR_COL, COLOR_COL, ElementDataType.integer.name(), null));
OrderedColumns orderedColumns = new OrderedColumns(APP_NAME, TABLE_ID_1, columns);
//Define the table's rows
Row row;
row= new Row(rowEntries, table);
table.addRow(row);
return new TypedRow(table.getRowAtIndex(0),orderedColumns);
}

@NonNull
private static BaseTable getBaseTable() {
String[] primaryKey = {"id"};
String[] elementKeys = {
MY_ELEMENT_1, MY_ELEMENT_2, MY_ELEMENT_3, MY_ELEMENT_4, MY_ELEMENT_5, MY_ELEMENT_6
Expand All @@ -312,17 +341,9 @@ private TypedRow setupTableWithRowEntriesAndReturnTypedRow(String[] rowEntries){
elementKeyToIndex.put(MY_ELEMENT_4,3);
elementKeyToIndex.put(MY_ELEMENT_5,4);
elementKeyToIndex.put(MY_ELEMENT_6,5);
BaseTable table = new BaseTable(primaryKey, elementKeys, elementKeyToIndex, 1);
//Define the table's column
List<Column> columns = new ArrayList<>();
columns.add(new Column(COLOR_COL, COLOR_COL, ElementDataType.integer.name(), null));
OrderedColumns orderedColumns = new OrderedColumns(APP_NAME, TABLE_ID_1, columns);
//Define the table's rows
Row row;
row= new Row(rowEntries, table);
table.addRow(row);
return new TypedRow(table.getRowAtIndex(0),orderedColumns);
return new BaseTable(primaryKey, elementKeys, elementKeyToIndex, 1);
}

private void updateColorRule(String colName, String value, ColorRule.RuleType operator){
cr.setColumnElementKey(colName);
cr.setVal(value);
Expand Down