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);
}
Aggregations