Package com.mysema.query.collections

Source Code of com.mysema.query.collections.PathMatcherTest

package com.mysema.query.collections;

import static org.hamcrest.core.IsEqual.equalTo;
import static com.mysema.query.collections.PathMatcher.hasValue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;

import org.hamcrest.Description;
import org.hamcrest.StringDescription;
import org.junit.Test;

public class PathMatcherTest {
   
    private static final QCar $ = QCar.car;

    @Test
    public void Match() {
        Car car = new Car();
        car.setHorsePower(123);
       
        assertThat(car, hasValue($.horsePower));
        assertThat(car, hasValue($.horsePower, equalTo(123)));
    }
   
    @Test
    public void Mismatch() {
        Car car = new Car();
        car.setHorsePower(123);
       
        Description mismatchDescription = new StringDescription();
        hasValue($.horsePower, equalTo(321)).describeMismatch(car, mismatchDescription);
        assertEquals("value \"car.horsePower\" was <123>", mismatchDescription.toString());
    }
   
    @Test
    public void Describe() {
        Description description = new StringDescription();
        hasValue($.horsePower, equalTo(321)).describeTo(description);
        assertEquals("valueOf(\"car.horsePower\", <321>)", description.toString());
    }
   
}
TOP

Related Classes of com.mysema.query.collections.PathMatcherTest

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.