Search in sources :

Example 41 with SearchCriterion

use of com.qcadoo.model.api.search.SearchCriterion in project mes by qcadoo.

the class DeliveredProductHooksTest method init.

@Before
public void init() {
    deliveredProductHooks = new DeliveredProductHooks();
    MockitoAnnotations.initMocks(this);
    PowerMockito.mockStatic(SearchRestrictions.class);
    when(deliveredProduct.getBelongsToField(DELIVERY)).thenReturn(delivery);
    when(deliveredProduct.getBelongsToField(PRODUCT)).thenReturn(product);
    PowerMockito.mockStatic(PluginUtils.class);
    when(PluginUtils.isEnabled("supplyNegotiations")).thenReturn(false);
    when(deliveredProductDD.find()).thenReturn(searchCriteriaBuilder);
    Long id = 1L;
    when(deliveredProduct.getId()).thenReturn(id);
    SearchCriterion criterion1 = SearchRestrictions.belongsTo(DELIVERY, delivery);
    SearchCriterion criterion2 = SearchRestrictions.belongsTo(PRODUCT, product);
    SearchCriterion criterion3 = SearchRestrictions.ne("id", id);
    when(searchCriteriaBuilder.add(criterion1)).thenReturn(searchCriteriaBuilder);
    when(searchCriteriaBuilder.add(criterion2)).thenReturn(searchCriteriaBuilder);
    when(searchCriteriaBuilder.add(criterion3)).thenReturn(searchCriteriaBuilder);
    when(searchCriteriaBuilder.setMaxResults(1)).thenReturn(searchCriteriaBuilder);
}
Also used : SearchCriterion(com.qcadoo.model.api.search.SearchCriterion) Before(org.junit.Before)

Aggregations

SearchCriterion (com.qcadoo.model.api.search.SearchCriterion)41 Entity (com.qcadoo.model.api.Entity)16 Test (org.junit.Test)12 SearchCriteriaBuilder (com.qcadoo.model.api.search.SearchCriteriaBuilder)7 FieldDefinition (com.qcadoo.model.api.FieldDefinition)6 DataDefinition (com.qcadoo.model.api.DataDefinition)4 SearchProjection (com.qcadoo.model.api.search.SearchProjection)4 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)4 SearchResult (com.qcadoo.model.api.search.SearchResult)3 BigDecimal (java.math.BigDecimal)2 Date (java.util.Date)2 Before (org.junit.Before)2 Matchers.anyString (org.mockito.Matchers.anyString)2 ImmutableList (com.google.common.collect.ImmutableList)1 BatchNumberUniqueness (com.qcadoo.mes.advancedGenealogy.constants.BatchNumberUniqueness)1 AssignmentToShiftCriteria (com.qcadoo.mes.assignmentToShift.dataProviders.AssignmentToShiftCriteria)1 SearchDisjunction (com.qcadoo.model.api.search.SearchDisjunction)1 SearchOrder (com.qcadoo.model.api.search.SearchOrder)1 ParseException (java.text.ParseException)1 List (java.util.List)1