Package company.predicates

Source Code of company.predicates.SalaryOver9000PredicateTest

package company.predicates;

import company.IPredicate;
import employee.IEmployee;
import org.junit.Before;
import org.junit.Test;

import java.math.BigDecimal;

import static org.fest.assertions.Assertions.assertThat;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;

/**
* Created by Wojciech Milewski.
*/
public class SalaryOver9000PredicateTest {
    private IPredicate predicate;

    @Before
    public void setUp() {
        predicate = new SalaryOver9000Predicate();
    }

    @Test
    public void apply_ShouldReturnFalseIfSalaryOfGivenEmployeeIsBelow9000() {
        //given
        IEmployee employee = mock(IEmployee.class);
        given(employee.getSalary()).willReturn(BigDecimal.valueOf(3000));
        //when
        final Boolean apply = predicate.apply(employee);
        //then
        assertThat(apply).isEqualTo(Boolean.FALSE);
    }

    @Test
    public void apply_ShouldReturnTrueIfSalaryOfGivenEmployeeIsOver9000() throws Exception {
        //given
        IEmployee employee = mock(IEmployee.class);
        given(employee.getSalary()).willReturn(BigDecimal.valueOf(10000));
        //when
        final Boolean apply = predicate.apply(employee);
        //then
        assertThat(apply).isEqualTo(Boolean.TRUE);
    }
}
TOP

Related Classes of company.predicates.SalaryOver9000PredicateTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.