Skip to content

Commit

Permalink
Apply style suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
Ndiritu committed Sep 11, 2024
1 parent 70bc888 commit 631f1cf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ public void setIsInitializationCompleted(final boolean value) {
BackedModel backedModel = (BackedModel) item;
backedModel
.getBackingStore()
.setIsInitializationCompleted(value); // propagate initialization
.setIsInitializationCompleted(
value); // propagate initialization
}
}
}
Expand Down Expand Up @@ -112,9 +113,7 @@ public void setReturnOnlyChangedValues(final boolean value) {
for (final Object item : items) {
if (item instanceof BackedModel) {
BackedModel backedModel = (BackedModel) item;
backedModel
.getBackingStore()
.setReturnOnlyChangedValues(value);
backedModel.getBackingStore().setReturnOnlyChangedValues(value);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -465,22 +465,6 @@ void TestsBackingStoreUpdateToItemInNestedCollectionWithAnotherBackedModel() {
.containsKey("manager"));
}

@Test
void testLargeArraysPerformsWell() {
// Arrange
var testBackingStore = new InMemoryBackingStore();
// Act
assertTrue(testBackingStore.enumerate().isEmpty());
var testArray = new int[100000000];
testBackingStore.set("values", testArray);
long startTimeMillis = System.currentTimeMillis();
testBackingStore.setIsInitializationCompleted(true);
long timeTakenMillis = System.currentTimeMillis() - startTimeMillis;

// Assert
assertTrue(timeTakenMillis < 1);
}

@Test
void testInitializationCompletedIsPropagatedToMapItems() {
var colleagues = new HashMap<String, Object>();
Expand Down Expand Up @@ -523,7 +507,6 @@ void testInitializationCompletedIsPropagatedToCollectionItems() {
for (TestEntity colleague : testUser.getValue()) {
assertTrue(colleague.getBackingStore().getIsInitializationCompleted());
}

}

@Test
Expand Down Expand Up @@ -555,15 +538,17 @@ void testCollectionPropertyConsistencyChecksSizeChangesInAllNestedItemsInCollect
testUser.getBackingStore().setReturnOnlyChangedValues(false);
testUser.getColleagues().get(9).getAdditionalData().put("moreRandom", 123);

// collection consistency should loop through all nested backed models in the collection and find one with a dirty additional data map
// collection consistency should loop through all nested backed models in the collection and
// find one with a dirty additional data map
testUser.getBackingStore().setReturnOnlyChangedValues(true);
assertNotNull(testUser.getColleagues());
var changedValues = testUser.getBackingStore().enumerate();
assertEquals(1, changedValues.size());
}

@Test
void testCollectionPropertyConsistencyChecksEnumeratesNestedBackedModelsInAllNestedCollections() {
void
testCollectionPropertyConsistencyChecksEnumeratesNestedBackedModelsInAllNestedCollections() {
var colleagues = new ArrayList<TestEntity>();
for (int i = 0; i < 10; i++) {
var colleague = new TestEntity();
Expand All @@ -589,9 +574,12 @@ void testCollectionPropertyConsistencyChecksEnumeratesNestedBackedModelsInAllNes

// Update nested backed model
testUser.getBackingStore().setReturnOnlyChangedValues(false);
((TestEntity) testUser.getColleagues().get(9).getAdditionalData().get("manager")).getAdditionalData().put("moreRandom", 123);
((TestEntity) testUser.getColleagues().get(9).getAdditionalData().get("manager"))
.getAdditionalData()
.put("moreRandom", 123);

// collection consistency should loop through all nested backed models in the collection and find one with a dirty additional data map
// collection consistency should loop through all nested backed models in the collection and
// find one with a dirty additional data map
testUser.getBackingStore().setReturnOnlyChangedValues(true);
var changedValues = testUser.getBackingStore().enumerate();
assertNotNull(testUser.getColleagues());
Expand Down

0 comments on commit 631f1cf

Please sign in to comment.