Search in sources :

Example 21 with SearchCriterion

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

the class StaffAssignmentToShiftDetailsHooksTest method shouldEnabledProductionLineAndDisableOccupationTypeNameFieldsWhenWorkOnLineIsSelected.

@Test
public void shouldEnabledProductionLineAndDisableOccupationTypeNameFieldsWhenWorkOnLineIsSelected() {
    // given
    String dictionaryName = "Praca na linii";
    String technicalCode = "01workOnLine";
    given(occupationType.getFieldValue()).willReturn(dictionaryName);
    SearchCriterion criterion = SearchRestrictions.eq(NAME, dictionaryName);
    given(builder.add(criterion)).willReturn(builder);
    given(builder.uniqueResult()).willReturn(dictionary);
    given(dictionary.getStringField(TECHNICAL_CODE)).willReturn(technicalCode);
    // when
    detailsHooks.setFieldsEnabledWhenTypeIsSpecific(view);
    // then
    verify(productionLine).setVisible(true);
    verify(occupationTypeName).setVisible(false);
}
Also used : SearchCriterion(com.qcadoo.model.api.search.SearchCriterion) Test(org.junit.Test)

Example 22 with SearchCriterion

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

the class StaffAssignmentToShiftDetailsHooksTest method shouldDisabledProductionLineAndOccupationTypeNameFieldsWhenEmptyIsSelected.

@Test
public void shouldDisabledProductionLineAndOccupationTypeNameFieldsWhenEmptyIsSelected() {
    // given
    String dictionaryName = "";
    given(occupationType.getFieldValue()).willReturn(dictionaryName);
    SearchCriterion criterion = SearchRestrictions.eq(NAME, dictionaryName);
    given(builder.add(criterion)).willReturn(builder);
    given(builder.uniqueResult()).willReturn(null);
    // when
    detailsHooks.setFieldsEnabledWhenTypeIsSpecific(view);
    // then
    verify(productionLine).setVisible(false);
    verify(occupationTypeName).setVisible(false);
}
Also used : SearchCriterion(com.qcadoo.model.api.search.SearchCriterion) Test(org.junit.Test)

Example 23 with SearchCriterion

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

the class StaffAssignmentToShiftDetailsHooksTest method shouldntSetOccupationTypeToDefaultWhenDictionaryIsNull.

@Test
public void shouldntSetOccupationTypeToDefaultWhenDictionaryIsNull() {
    // given
    given(staffAssignmentToShiftForm.getEntityId()).willReturn(null);
    given(occupationType.getFieldValue()).willReturn(null);
    SearchCriterion criterion = SearchRestrictions.eq(TECHNICAL_CODE, WORK_ON_LINE.getStringValue());
    given(builder.add(criterion)).willReturn(builder);
    given(builder.uniqueResult()).willReturn(null);
    // when
    detailsHooks.setOccupationTypeToDefault(view);
    // then
    verify(occupationType, never()).setFieldValue(Mockito.anyString());
}
Also used : SearchCriterion(com.qcadoo.model.api.search.SearchCriterion) Test(org.junit.Test)

Example 24 with SearchCriterion

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

the class AssignmentToShiftStatesHelper method findPausedStateChangeEntity.

private Entity findPausedStateChangeEntity(final Entity assignmentToShift) {
    DataDefinition stateChangeDD = dataDefinitionService.get(AssignmentToShiftConstants.PLUGIN_IDENTIFIER, AssignmentToShiftConstants.MODEL_ASSIGNMENT_TO_SHIFT_STATE_CHANGE);
    SearchCriteriaBuilder scb = stateChangeDD.find();
    for (SearchCriterion criterion : getCriteriaToFindWaitingStateChange(assignmentToShift)) {
        scb.add(criterion);
    }
    return scb.setMaxResults(1).uniqueResult();
}
Also used : SearchCriteriaBuilder(com.qcadoo.model.api.search.SearchCriteriaBuilder) SearchCriterion(com.qcadoo.model.api.search.SearchCriterion) DataDefinition(com.qcadoo.model.api.DataDefinition)

Example 25 with SearchCriterion

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

the class StaffAssignmentToShiftDetailsHooksTest method shouldDisabledProductionLineAndOccupationTypeNameFieldsWhenMixDictionaryIsSelected.

@Test
public void shouldDisabledProductionLineAndOccupationTypeNameFieldsWhenMixDictionaryIsSelected() {
    // given
    String dictionaryName = "MIX";
    given(occupationType.getFieldValue()).willReturn(dictionaryName);
    SearchCriterion criterion = SearchRestrictions.eq(NAME, dictionaryName);
    given(builder.add(criterion)).willReturn(builder);
    given(builder.uniqueResult()).willReturn(dictionary);
    given(dictionary.getStringField(TECHNICAL_CODE)).willReturn(Mockito.anyString());
    // when
    detailsHooks.setFieldsEnabledWhenTypeIsSpecific(view);
    // then
    verify(productionLine).setVisible(false);
    verify(occupationTypeName).setVisible(false);
}
Also used : SearchCriterion(com.qcadoo.model.api.search.SearchCriterion) Test(org.junit.Test)

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