예제 #1
0
 @Test
 public void
     evaluatingAParsedCoalesceExpression_NullAndAStringWithQuotationMarks_RetunsQuotationMarks()
         throws Exception {
   Expression e = Coalesce.parse("null ?? \"\\\"\\\"\\\"\\\"\"");
   assertThat(e.evaluate(), is(equalTo("\\\"\\\"\\\"\\\"")));
 }
예제 #2
0
 @Test
 public void createCoalesceExpression_ObjectAndStringOperands_ReturnClassIsString() {
   Class<?> expectedClass = Object.class;
   Object left = new Object();
   Object right = "1";
   Expression e = coalesce(left, right);
   assertThat(e.getResultClass(), is(assignableTo(expectedClass)));
 }
예제 #3
0
 @Test
 public void createCoalesceExpression_NullAndObjectOperands_ReturnClassIsString() {
   Class<?> expectedClass = String.class;
   Object left = null;
   Object right = new String();
   Expression e = coalesce(left, right);
   assertThat(e.getResultClass(), is(assignableTo(expectedClass)));
 }
예제 #4
0
 @Test
 public void evaluateCoalesceExpression_NotNullOnLeft_ReturnsLeft() throws Exception {
   Expression e = coalesce(constant("1"), constant("2"));
   assertThat(e.evaluate(), is(equalTo("1")));
 }
예제 #5
0
 @Test
 public void evaluatingAParsedCoalesceExpression_AAndB_RetunsA() throws Exception {
   Expression e = Coalesce.parse("\"a\" ?? \"b\"");
   assertThat(e.evaluate(), is(equalTo("a")));
 }
예제 #6
0
 @Test
 public void createCoalesceExpression_callingToString_getsJavaLikeExpression() {
   Expression e = coalesce("a", "b");
   assertThat(e.toString(), is("\"a\" ?? \"b\""));
 }