Buggy code:
@ RunWith ( PowerMockRunner . class ) public class QualityControlServiceTest { private SecurityService securityService = null ; private QualityControlService qualityControlService ; private DataDefinitionService dataDefinitionService ; private TranslationService translationService ; private QualityControlForNumberService qualityControlForNumber ; private Integer DIGITS_NUMBER = 6 ; @ Before public void init ( ) { } @ Test public void shouldSetRequiredOnCommentForControlResult ( ) { } @ Test public void shouldSetRequiredOnCommentForDefects ( ) { } @ Test public void shouldSetRequiredOnCommentAfterSelectChange ( ) { } @ Test public void shouldSetErrorOnCommentFieldForResultType ( ) { } @ Test public void shouldSetErrorOnCommentFieldForAcceptedDefectsQuantity ( ) { } @ Test public void shouldCloseQualityControlForEntityComponentState ( ) { } @ Test public void shouldCloseQualityControlForIGridComponentState ( ) { } @ Test public void shouldAddFailureMessageOnEmptyControlResultTypeForFormComponent ( ) { } @ Test public void shouldAddFailureMessageOnEmptyControlResultTypeForGridComponent ( ) { } @ Test public void shouldAddFailureMessageOnNoValueForFormComponent ( ) { } @ Test public void shouldAddFailureMessageOnNoValueForNonFormComponent ( ) { } @ Test public void shouldGenerateQualityControlForBatch ( ) { } @ Test public void shouldGenerateQualityControlForUnit ( ) { } @ Test public void shouldEnableCalendarsOnPreRender ( ) { } @ Test public void shouldSetQuantitiesToDefaultsIfEmpty ( ) { } @ Test public void shouldSetCommentAsRequiredOnPositiveDefectsQuantity ( ) { } @ Test public void shouldSetCommentAsNotRequiredOnPositiveDefectsQuantity ( ) { } @ Test public void shouldSetQualityControlInstructionToDefaultFromTechnology ( ) { ViewDefinitionState viewDefinitionState = mock ( ViewDefinitionState . class ) ; FieldComponent state = mock ( FieldComponent . class ) ; FieldComponent controlInstruction = mock ( FieldComponent . class ) ; DataDefinition orderDD = mock ( DataDefinition . class , RETURNS_DEEP_STUBS ) ; DataDefinition technologyDD = mock ( DataDefinition . class , RETURNS_DEEP_STUBS ) ; SearchCriteriaBuilder searchCriteria = mock ( SearchCriteriaBuilder . class , RETURNS_DEEP_STUBS ) ; Entity technology = new com . qcadoo . model . internal . DefaultEntity ( technologyDD ) ; technology . setField ( "qualityControlInstruction" , "test" ) ; List < Entity > orders = new ArrayList < Entity > ( ) ; Entity genealogy = new com . qcadoo . model . internal . DefaultEntity ( orderDD ) ; genealogy . setField ( "technology" , technology ) ; orders . add ( genealogy ) ; given ( viewDefinitionState . getComponentByReference ( "controlInstruction" ) ) . willReturn ( controlInstruction ) ; given ( state . getFieldValue ( ) ) . willReturn ( 1L ) ; given ( dataDefinitionService . get ( "orders" , "order" ) ) . willReturn ( orderDD ) ; <START_BUG> given ( orderDD . find ( ) . setMaxResults ( 1 ) . isIdEq ( Mockito . anyLong ( ) ) ) . willReturn ( searchCriteria ) ; <END_BUG> given ( searchCriteria . list ( ) . getEntities ( ) ) . willReturn ( orders ) ; qualityControlService . setQualityControlInstruction ( viewDefinitionState , state , new String [ ] { } ) ; verify ( controlInstruction ) . setFieldValue ( "" ) ; verify ( controlInstruction ) . setFieldValue ( "test" ) ; } @ Test public void shouldSetOperationAsRequired ( ) { } @ Test public void shouldSetQualityControlTypeHiddenFieldToQualityControlsForBatch ( ) { } @ Test public void shouldSetErrorMessageOnEmptyOperationField ( ) { } @ Test public void shouldSetQuantitiesToDefaultValues ( ) { } @ Test public void shouldAddErrorMessageOnTooLargeRejectedQuantity ( ) { } @ Test public void shouldAddErrorMessageOnTooLargeAcceptedDefectsQuantity ( ) { } No newline ; at end ; of file ; }

Fix:
given ( orderDD . find ( ) . setMaxResults ( 1 ) . add ( SearchRestrictions . eq ( "id" , Mockito . anyLong ( ) ) ) ) . willReturn ( searchCriteria ) ;