Skip to content

Commit dff5b1f

Browse files
committed
Polishing
1 parent fa0a4a0 commit dff5b1f

File tree

1 file changed

+41
-23
lines changed

1 file changed

+41
-23
lines changed
Lines changed: 41 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -29,52 +29,70 @@
2929
/**
3030
* @author Andy Clement
3131
*/
32-
public class LiteralExpressionTests {
32+
class LiteralExpressionTests {
33+
34+
private final LiteralExpression lEx = new LiteralExpression("somevalue");
35+
36+
37+
@Test
38+
void getValue() throws Exception {
39+
assertThat(lEx.getValue()).isEqualTo("somevalue");
40+
assertThat(lEx.getValue(String.class)).isEqualTo("somevalue");
41+
assertThat(lEx.getValue(new Rooty())).isEqualTo("somevalue");
42+
assertThat(lEx.getValue(new Rooty(), String.class)).isEqualTo("somevalue");
43+
}
3344

3445
@Test
35-
public void testGetValue() throws Exception {
36-
LiteralExpression lEx = new LiteralExpression("somevalue");
37-
assertThat(lEx.getValue()).isInstanceOf(String.class).isEqualTo("somevalue");
38-
assertThat(lEx.getValue(String.class)).isInstanceOf(String.class).isEqualTo("somevalue");
46+
void getValueWithSuppliedEvaluationContext() throws Exception {
3947
EvaluationContext ctx = new StandardEvaluationContext();
40-
assertThat(lEx.getValue(ctx)).isInstanceOf(String.class).isEqualTo("somevalue");
41-
assertThat(lEx.getValue(ctx, String.class)).isInstanceOf(String.class).isEqualTo("somevalue");
42-
assertThat(lEx.getValue(new Rooty())).isInstanceOf(String.class).isEqualTo("somevalue");
43-
assertThat(lEx.getValue(new Rooty(), String.class)).isInstanceOf(String.class).isEqualTo("somevalue");
44-
assertThat(lEx.getValue(ctx, new Rooty())).isInstanceOf(String.class).isEqualTo("somevalue");
45-
assertThat(lEx.getValue(ctx, new Rooty(),String.class)).isInstanceOf(String.class).isEqualTo("somevalue");
48+
assertThat(lEx.getValue(ctx)).isEqualTo("somevalue");
49+
assertThat(lEx.getValue(ctx, String.class)).isEqualTo("somevalue");
50+
assertThat(lEx.getValue(ctx, new Rooty())).isEqualTo("somevalue");
51+
assertThat(lEx.getValue(ctx, new Rooty(), String.class)).isEqualTo("somevalue");
52+
}
53+
54+
@Test
55+
void getExpressionString() {
4656
assertThat(lEx.getExpressionString()).isEqualTo("somevalue");
57+
}
58+
59+
@Test
60+
void isWritable() throws Exception {
4761
assertThat(lEx.isWritable(new StandardEvaluationContext())).isFalse();
4862
assertThat(lEx.isWritable(new Rooty())).isFalse();
4963
assertThat(lEx.isWritable(new StandardEvaluationContext(), new Rooty())).isFalse();
5064
}
5165

52-
static class Rooty {}
53-
5466
@Test
55-
public void testSetValue() {
56-
assertThatExceptionOfType(EvaluationException.class).isThrownBy(() ->
57-
new LiteralExpression("somevalue").setValue(new StandardEvaluationContext(), "flibble"))
67+
void setValue() {
68+
assertThatExceptionOfType(EvaluationException.class)
69+
.isThrownBy(() -> lEx.setValue(new StandardEvaluationContext(), "flibble"))
5870
.satisfies(ex -> assertThat(ex.getExpressionString()).isEqualTo("somevalue"));
59-
assertThatExceptionOfType(EvaluationException.class).isThrownBy(() ->
60-
new LiteralExpression("somevalue").setValue(new Rooty(), "flibble"))
71+
assertThatExceptionOfType(EvaluationException.class)
72+
.isThrownBy(() -> lEx.setValue(new Rooty(), "flibble"))
6173
.satisfies(ex -> assertThat(ex.getExpressionString()).isEqualTo("somevalue"));
62-
assertThatExceptionOfType(EvaluationException.class).isThrownBy(() ->
63-
new LiteralExpression("somevalue").setValue(new StandardEvaluationContext(), new Rooty(), "flibble"))
74+
assertThatExceptionOfType(EvaluationException.class)
75+
.isThrownBy(() -> lEx.setValue(new StandardEvaluationContext(), new Rooty(), "flibble"))
6476
.satisfies(ex -> assertThat(ex.getExpressionString()).isEqualTo("somevalue"));
6577
}
6678

6779
@Test
68-
public void testGetValueType() throws Exception {
69-
LiteralExpression lEx = new LiteralExpression("somevalue");
80+
void getValueType() throws Exception {
7081
assertThat(lEx.getValueType()).isEqualTo(String.class);
7182
assertThat(lEx.getValueType(new StandardEvaluationContext())).isEqualTo(String.class);
7283
assertThat(lEx.getValueType(new Rooty())).isEqualTo(String.class);
7384
assertThat(lEx.getValueType(new StandardEvaluationContext(), new Rooty())).isEqualTo(String.class);
85+
}
86+
87+
@Test
88+
void getValueTypeDescriptor() throws Exception {
7489
assertThat(lEx.getValueTypeDescriptor().getType()).isEqualTo(String.class);
7590
assertThat(lEx.getValueTypeDescriptor(new StandardEvaluationContext()).getType()).isEqualTo(String.class);
7691
assertThat(lEx.getValueTypeDescriptor(new Rooty()).getType()).isEqualTo(String.class);
7792
assertThat(lEx.getValueTypeDescriptor(new StandardEvaluationContext(), new Rooty()).getType()).isEqualTo(String.class);
7893
}
7994

95+
96+
static class Rooty {}
97+
8098
}

0 commit comments

Comments
 (0)