package com.cron.utils.parser.field;

import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;

public class AndTest {

    private And and;
    private FieldExpression expression1;
    private FieldExpression expression2;

    @Before
    public void setUp() throws Exception {
        and = new And();
        expression1 = mock(FieldExpression.class);
        expression2 = mock(FieldExpression.class);
    }

    @Test
    public void testAnd() throws Exception {
        and.and(expression1).and(expression2);
        assertEquals(2, and.getExpressions().size());
        assertEquals(expression1, and.getExpressions().get(0));
        assertEquals(expression2, and.getExpressions().get(1));
    }

    @Test(expected = UnsupportedOperationException.class)
    public void testGetExpressionsImmutable() throws Exception {
        and.and(expression1).getExpressions().add(expression2);
    }
}
@@ -164,16 +164,56 @@
 to.mock;
+%0Aimport static org.mockito.Mockito.when;
 %0A%0Apublic
@@ -1006,10 +1006,460 @@
 );%0A    %7D
+%0A%0A    @Test%0A    public void testAString() throws Exception %7B%0A        String expression1String = %22expression1%22;%0A        String expression2String = %22expression2%22;%0A        when(expression1.asString()).thenReturn(expression1String);%0A        when(expression2.asString()).thenReturn(expression2String);%0A        and.and(expression1).and(expression2);%0A%0A        assertEquals(String.format(%22%25s,%25s%22, expression1String, expression2String), and.asString());%0A    %7D
 %0A%7D

Add test for And