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