Skip to content

Commit

Permalink
Addressed PR comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
millems committed Sep 9, 2024
1 parent c96bef3 commit 9ed97a3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,6 @@ private void internalPut(Key<?> key, Value<?> value) {
if (oldValue != null) {
dependencyGraph.valueUpdated(oldValue, value);
}

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import java.util.concurrent.TimeUnit;
import org.junit.Test;
import org.mockito.Mockito;
import org.w3c.dom.Attr;

public class AttributeMapTest {

Expand Down Expand Up @@ -158,6 +157,20 @@ public void lazyAttributes_notReResolvedAfterToBuilderBuild() {
verify(lazyRead, Mockito.times(1)).run();
}

@Test
public void lazyAttributes_canUpdateTheMap_andBeUpdatedWithPutLazyIfAbsent() {
AttributeMap.Builder map = AttributeMap.builder();
map.putLazyIfAbsent(STRING_KEY, c -> {
// Force a modification to the underlying map. We wouldn't usually do this so explicitly, but
// this can happen internally within AttributeMap when resolving uncached lazy values,
// so it needs to be possible.
map.put(INTEGER_KEY, 0);
return "string";
});
map.putLazyIfAbsent(STRING_KEY, c -> "string"); // Force the value to be resolved within the putLazyIfAbsent
assertThat(map.get(STRING_KEY)).isEqualTo("string");
}

@Test
public void changesInBuilder_doNotAffectBuiltMap() {
AttributeMap.Builder builder = mapBuilderWithLazyString();
Expand Down

0 comments on commit 9ed97a3

Please sign in to comment.