Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added tests for the TableMetaDataEntries class #318

Open
wants to merge 10 commits into
base: upgrade-jdk11
Choose a base branch
from

Conversation

bqcarima
Copy link

@bqcarima bqcarima commented Mar 25, 2025

This pull request addresses odk-x/tool-suite-X#522 by adding tests for the TableMetaDataEntries and KeyValueStoreEntry classes under data.

Added tests for the TableMetaDataEntries class
testDataBaseInitialization
Verifies that the database was created and is empty upon creation.

testAddEntry
Verifies that an entry made to the database is successful.

testDescribeContents
Tests the content description accuracy.

testWriteToParcel
Tests that the data written to a parcel is successful and reads the data to make sure data integrity is maintained.

testEntryOrderPreservation
Verifies that entries are stored in the order in which they were added.

Screenshot 2025-03-25 165508

Added tests for the KeyValueStoreEntry class

testKeyValueStoreEntryInitialization
Tests that a KeyValueStoreEntry object is initialized correctly and it is empty on creation.

testToString
Tests that the content of a KeyValueStoreEntry object is correctly converted to a string.

testHashCodeConsistency
Validates hash code consistency of a KeyValueStoreEntry object and the same instance of that object stored in a parcel.

testHashCodeDifference
Validates hash code difference of two KeyValueStoreEntry objects.

testEqualsNull
Validates of inequality of a KeyValueStoreEntry against a null KeyValueStoreEntry object.

testEqualsSameObject
Test of equality of a KeyValueStoreEntry against itself.

testEqualsDifferentObject
Test for inequality of a KeyValueStoreEntry object against another KeyValueStoreEntry object.

testEqualsTypeMismatch
Test for inequality of a KeyValueStoreEntry object against an object of a different type.

testCompareToPartition
Verifies the comparison and sorting of two KeyValueStoreEntry objects based on their partition attributes.

testCompareToAspect
Verifies the comparison and sorting of two KeyValueStoreEntry objects based on their aspect attributes.

testCompareToKey
Verifies the comparison and sorting of two KeyValueStoreEntry objects based on their key attributes.

testToCompareEquality
Verifies comparison of equality of two KeyValueStoryEntry objects.

testDescribeContents
Tests the content description accuracy.

testWriteToParcel
Verifies that the data written to a parcel is successful and reads the data to ensure data integrity is maintained.

Screenshot 2025-03-28 052237

Copy link
Member

@wbrunette wbrunette left a comment

Choose a reason for hiding this comment

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

good start

public class TableMetaDataEntriesTest {

//
TableMetaDataEntries testMetaDataEntries;
Copy link
Member

Choose a reason for hiding this comment

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

Why are TableMetaDataEntries are not private? Do you expect other test classes to access them from a different class?

Copy link
Author

Choose a reason for hiding this comment

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

No sir. I have made another commit reflecting the required changes.

private final String TABLE_ID = "testTable";
private final String REV_ID = "revId";
KeyValueStoreEntry entry1 = new KeyValueStoreEntry();
KeyValueStoreEntry entry2 = new KeyValueStoreEntry();
Copy link
Member

Choose a reason for hiding this comment

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

Why are entry1 and entry2 not private? Do you expect other test classes to access them from a different class?

Copy link
Author

Choose a reason for hiding this comment

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

No sir, new changes have limited access to the test class.

entry1.aspect = "aspect1";
entry1.key = "key1";
entry1.type = "number";
entry1.value = "value1";
Copy link
Member

Choose a reason for hiding this comment

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

use string constants so you can then reuse string constants in assert statements

}


}
Copy link
Member

Choose a reason for hiding this comment

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

add a new line to the end of the file

…anges: made testMetaDataEntries private, ENTRY_1,and ENTRY_2 private and final
…ed in tests. Refrectored testAddEntry to check for data integrity.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants