@Test public void getAllAvailableColors() throws Exception { ColorType color = new ColorType(1, "yellow"); List<ColorType> colorList = Arrays.asList(color); when(colorTypeRepo.findByAvailable(true)).thenReturn(colorList); DataResponse<ColorType> result = operations.getActiveColors(); verify(colorTypeRepo, times(1)).findByAvailable(true); assertEquals(result.getData().get(0).getId(), color.getId()); }
public DataResponse<ColorType> getActiveColors() { DataResponse<ColorType> response = new DataResponse<ColorType>("Could not get color list"); List<ColorType> colors = colorTypeRepo.findByAvailable(true); if (colors == null || colors.isEmpty()){ ErrorType.COLOR_CANT_FIND_BY_TYPE.throwException(); } response.setSuccess(true); response.setMessage("Succesfully returned all available colors"); response.setData(colors); response.setHttpStatus(HttpStatus.ACCEPTED); return response; }
ColorTypeOperations { public DataResponse<ColorType> getActiveColors() { DataResponse<ColorType> response = new DataResponse<ColorType>("Could not get color list"); List<ColorType> colors = colorTypeRepo.findByAvailable(true); if (colors == null || colors.isEmpty()){ ErrorType.COLOR_CANT_FIND_BY_TYPE.throwException(); } response.setSuccess(true); response.setMessage("Succesfully returned all available colors"); response.setData(colors); response.setHttpStatus(HttpStatus.ACCEPTED); return response; } }
ColorTypeOperations { public DataResponse<ColorType> getActiveColors() { DataResponse<ColorType> response = new DataResponse<ColorType>("Could not get color list"); List<ColorType> colors = colorTypeRepo.findByAvailable(true); if (colors == null || colors.isEmpty()){ ErrorType.COLOR_CANT_FIND_BY_TYPE.throwException(); } response.setSuccess(true); response.setMessage("Succesfully returned all available colors"); response.setData(colors); response.setHttpStatus(HttpStatus.ACCEPTED); return response; } ColorTypeOperations(ColorTypeRepo colorTypeRepo); }
ColorTypeOperations { public DataResponse<ColorType> getActiveColors() { DataResponse<ColorType> response = new DataResponse<ColorType>("Could not get color list"); List<ColorType> colors = colorTypeRepo.findByAvailable(true); if (colors == null || colors.isEmpty()){ ErrorType.COLOR_CANT_FIND_BY_TYPE.throwException(); } response.setSuccess(true); response.setMessage("Succesfully returned all available colors"); response.setData(colors); response.setHttpStatus(HttpStatus.ACCEPTED); return response; } ColorTypeOperations(ColorTypeRepo colorTypeRepo); DataResponse<ColorType> getAllColors(); DataResponse<ColorType> getActiveColors(); GenericResponse updateColorAvailability(Integer colorId, ColorTypeUpdateRequest request); DataResponse<ColorType> getInactiveColors(); }
ColorTypeOperations { public DataResponse<ColorType> getActiveColors() { DataResponse<ColorType> response = new DataResponse<ColorType>("Could not get color list"); List<ColorType> colors = colorTypeRepo.findByAvailable(true); if (colors == null || colors.isEmpty()){ ErrorType.COLOR_CANT_FIND_BY_TYPE.throwException(); } response.setSuccess(true); response.setMessage("Succesfully returned all available colors"); response.setData(colors); response.setHttpStatus(HttpStatus.ACCEPTED); return response; } ColorTypeOperations(ColorTypeRepo colorTypeRepo); DataResponse<ColorType> getAllColors(); DataResponse<ColorType> getActiveColors(); GenericResponse updateColorAvailability(Integer colorId, ColorTypeUpdateRequest request); DataResponse<ColorType> getInactiveColors();  }