Skip to content

Commit 3aff6ac

Browse files
committed
Cleanup commented out code and expected test results
1 parent 188ac3c commit 3aff6ac

File tree

6 files changed

+26
-29
lines changed

6 files changed

+26
-29
lines changed

src/main/java/com/hubspot/jinjava/util/EagerContextWatcher.java

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,7 @@ private static Map<String, Object> getBasicSpeculativeBindings(
209209
.peek(
210210
entry -> ((OneTimeReconstructible) entry.getValue()).setReconstructed(true)
211211
)
212-
.collect(
213-
Collectors.toMap(
214-
Entry::getKey,
215-
entry -> entry.getValue() //((OneTimeReconstructible) entry.getValue()).getOriginalValue()
216-
)
217-
)
212+
.collect(Collectors.toMap(Entry::getKey, Entry::getValue))
218213
);
219214
}
220215
return eagerExecutionResult
@@ -245,10 +240,7 @@ private static Map<String, Object> getBasicSpeculativeBindings(
245240
) {
246241
throw new CannotReconstructValueException(entry.getKey());
247242
}
248-
return new AbstractMap.SimpleImmutableEntry<>(
249-
entry.getKey(),
250-
contextValue //((DeferredValue) contextValue).getOriginalValue()
251-
);
243+
return new AbstractMap.SimpleImmutableEntry<>(entry.getKey(), contextValue);
252244
}
253245
return null;
254246
}
@@ -262,15 +254,7 @@ private static Map<String, Object> getBasicSpeculativeBindings(
262254
((DeferredValue) entry.getValue()).getOriginalValue() == null
263255
)
264256
)
265-
.collect(
266-
Collectors.toMap(
267-
Entry::getKey,
268-
entry -> entry.getValue()
269-
// entry.getValue() instanceof DeferredValue
270-
// ? ((DeferredValue) entry.getValue()).getOriginalValue()
271-
// : entry.getValue()
272-
)
273-
);
257+
.collect(Collectors.toMap(Entry::getKey, Entry::getValue));
274258
}
275259

276260
private static Map<String, Object> getAllSpeculativeBindings(
@@ -383,9 +367,6 @@ private static Object getOriginalValue(
383367
boolean isFullyResolved
384368
) {
385369
if (eagerChildContextConfig.takeNewValue || isFullyResolved) {
386-
if (e.getValue() instanceof DeferredValue) {
387-
// return ((DeferredValue) e.getValue()).getOriginalValue();
388-
}
389370
return e.getValue();
390371
}
391372

@@ -395,7 +376,7 @@ private static Object getOriginalValue(
395376
.get(e.getKey())
396377
.equals(getObjectOrHashCode(((DeferredValue) e.getValue()).getOriginalValue()))
397378
) {
398-
return e.getValue(); //((DeferredValue) e.getValue()).getOriginalValue();
379+
return e.getValue();
399380
}
400381

401382
// This is necessary if a state-changing function, such as .update()

src/test/java/com/hubspot/jinjava/EagerTest.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1367,8 +1367,17 @@ public void itAllowsDeferredLazyReferenceToGetOverriddenSecondPass() {
13671367
}
13681368

13691369
@Test
1370-
public void itE() {
1371-
interpreter.getContext().put("request", DeferredValue.instance());
1372-
expectedTemplateInterpreter.assertExpectedOutput("e");
1370+
public void itCommitsVariablesFromDoTagWhenPartiallyResolved() {
1371+
expectedTemplateInterpreter.assertExpectedOutput(
1372+
"commits-variables-from-do-tag-when-partially-resolved"
1373+
);
1374+
}
1375+
1376+
@Test
1377+
public void itCommitsVariablesFromDoTagWhenPartiallyResolvedSecondPass() {
1378+
interpreter.getContext().put("deferred", "resolved");
1379+
expectedTemplateInterpreter.assertExpectedNonEagerOutput(
1380+
"commits-variables-from-do-tag-when-partially-resolved.expected"
1381+
);
13731382
}
13741383
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
L1: ['a']
2+
L2: ['b', 'resolved']
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{% do %}
2+
3+
4+
{% set list2 = ['b'] %}{% do list2.append(deferred) %}
5+
{% enddo %}
6+
L1: ['a']
7+
L2: {{ list2 }}

src/test/resources/eager/e.jinja renamed to src/test/resources/eager/commits-variables-from-do-tag-when-partially-resolved.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
{% do list2.append(deferred) %}
55
{% enddo %}
66
L1: {{ list1 }}
7-
L2: {{ list2 }}
7+
L2: {{ list2 }}

src/test/resources/eager/e.expected.jinja

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)