public void testQuickServerLostCon() { try { assertEquals(0, TestEventHandler.getGotConnectedFlag()); assertEquals(0, TestEventHandler.getClosingConnectionFlag()); assertEquals(0, TestEventHandler.getLostConnectionFlag()); assertEquals(0, TestCommandHandler.getHandleCommandFlag()); client.connect(host, port); sleep(50); assertEquals(1, TestEventHandler.getGotConnectedFlag()); System.out.println("GotConnected Pass"); client.sendString("test1"); sleep(50); assertEquals(1, TestCommandHandler.getHandleCommandFlag()); assertEquals("test1", TestCommandHandler.getRequest()); System.out.println("HandleCommand 1 Pass"); client.close(); sleep(50); assertEquals(1, TestEventHandler.getLostConnectionFlag()); System.out.println("LostConnection Pass"); } catch (Exception e) { fail("Exception: " + e); } }
@Test public void testFindByIdWithClientServiceShouldPass() throws Exception { client.setName("test findById"); clientService.create(client); Integer insertedId = client.getId(); Client result = clientService.findById(insertedId); assertThat(result.getName(), is("test findById")); }
@Test public void testFindAllWithClientServiceShouldPass() throws Exception { List<Client> clients = clientService.findAll(); clientService.create(client); List<Client> result = clientService.findAll(); assertThat(result.size(), is(clients.size() + 1)); }
@Test public void testDeleteWithClientServiceShouldPass() throws Exception { clientService.create(client); Integer insertedId = client.getId(); Client delete = clientService.findById(insertedId); clientService.delete(delete); Client result = clientService.findById(delete.getId()); assertNull(result); }
protected void executeAction(ClientService svc, CreateTicketForm form) throws Exception { String purpose = form.getPurpose(); if (StringUtils.isEmptyOrNull(purpose)) { svc.getResponse() .sendError(HttpServletResponse.SC_FORBIDDEN, "You must supply a ticket purpose"); return; } String email = svc.getClientInfo().getPrimaryEmail(); String ticket = createTicket(purpose, email); svc.sendHeader(TICKET_HEADER, ticket); }
public String save() { if (client.getUser() == null) { client.setUser(getSessionUser()); } if (service.find(client.getClientId()) != null) { service.update(client); } else { service.create(client); } FacesContext.getCurrentInstance() .addMessage( null, new FacesMessage(FacesMessage.SEVERITY_INFO, "client saved successfully!", null)); return "list"; }
private Group createGroup(Client client) { Group group = new Group(); group.setName("Test Group" + RandomStringUtils.randomAlphanumeric(9)); group.setClient(clientService.reload(client)); groupService.save(group); return group; }
@RequestMapping(value = "/debt/{cid}", method = RequestMethod.GET) public String creditClient( ModelMap model, @PathVariable int cid, @ModelAttribute Payment payment) { model.addAttribute("client", clientService.getClientById(cid)); return "/auth/payment/paymentdebt"; }
@RequestMapping(value = "/credit/{cid}", method = RequestMethod.GET) public String chargeBalance( ModelMap modelMap, @ModelAttribute Payment payment, @PathVariable int cid) { modelMap.addAttribute("client", clientService.getClientById(cid)); return "/auth/payment/paymentcredit"; }
@Override @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) public Boolean remove(Long id) throws IabakoActionForbiddenException { saleDAO.deleteAttachedObjects(id); Sale sale = saleDAO.findById(id); if (sale == null) { log.warn("No sale found with id :" + id); return false; } stockRollBack(sale); Client client = sale.getClient(); boolean result = super.remove(id); if (client != null) { clientService.calculateStatus(client); } trackingService.addTrackingToUserSession(TrackingType.saleDelete, sale); return result; }
public void delete() { service.delete(client); FacesContext.getCurrentInstance() .addMessage( null, new FacesMessage(FacesMessage.SEVERITY_INFO, "client deleted successfully!", null)); }
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) public Sale calculateStatusAndSave(Sale sale, boolean isDraft) { sale.calculateStatus(isDraft); sale = (Sale) super.save(sale); if (!isDraft) { clientService.calculateStatus(sale.getClient()); } return sale; }
protected void loadData() { ClientService clientService = ClientService.getInstance(); clientService.listClientsForImport( this.group, master, new RemoteRequestCallback<List<ClientJSO>>() { @Override public void onRequestSuccess(List<ClientJSO> clients) { List<BeanModel> clientModels = clientFactory.createModel(clients); clientStore.removeAll(); clientStore.add(clientModels); clientsGrid.unmask(); } @Override public void onRequestFailed(Throwable th) { MessageDialog.showError( "Chyba při získávání seznamu klientů pro import: ", th.getMessage()); clientsGrid.unmask(); } }); }
public List<Client> list() { List<Client> subList = new ArrayList<Client>(); List<Client> fullList = new ArrayList<Client>(); User authorizedUser = getSessionUser(); logger.debug("Found authenticatedUser: "******"fullList:" + fullList + "\nsubList:" + subList.toString()); return subList; }
private Client createClient() { UserAdmin user = new UserAdmin(1l, 0); Client client = new Client(); client.setTier(new ClientTier(3l)); client.setContractEnd(LocalDate.now().plusYears(1)); client.setContractStart(LocalDate.now()); client.setRegion(new ClientRegion(1l)); client.setName("Test Client " + RandomStringUtils.randomAlphanumeric(18)); client.setType(new ClientType(1l)); client.setContractOwner(user); client.setActive(false); client.setSalesForceAccount(new SalesForce(RandomStringUtils.randomAlphanumeric(18))); clientService.create(client); return client; }
@RequestMapping(value = "/credit/{cid}", method = RequestMethod.POST) public String chargeBalanceP( ModelMap modelMap, @ModelAttribute Payment payment, @PathVariable int cid, @RequestParam(required = true) String type, RedirectAttributes redirectAttributes) { Client client = clientService.getClientById(cid); payment.setPaymentType(type); paymentService.increaseCredit(payment, client, "username"); redirectAttributes.addFlashAttribute("message", Messages.success); redirectAttributes.addFlashAttribute("client", client); redirectAttributes.addFlashAttribute("payment", payment); return "redirect:/auth/payment/credit/" + client.getId(); }
/** * Process the specified HTTP request, and create the corresponding HTTP response (or forward to * another web component that will create it). Return an <code>ActionForward</code> instance * describing where and how control should be forwarded, or <code>null</code> if the response has * already been completed. * * @param mapping The ActionMapping used to select this instance * @param form The optional ActionForm bean for this request (if any) * @param request The HTTP request we are processing * @param response The HTTP response we are creating * @exception Exception if business logic throws an exception */ public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { // Extract attributes we will need MessageResources messages = getResources(request); // save errors ActionMessages errors = new ActionMessages(); // START check for login (security) if (!SecurityService.getInstance().checkForLogin(request.getSession(false))) { return (mapping.findForward("welcome")); } // END check for login (security) // values for adding the related contact DynaValidatorForm qae2 = (DynaValidatorForm) form; // from wizard add clientContact String contactId = (String) request.getAttribute("clientContactViewId"); if (contactId == null) { contactId = (String) (qae2.get("contact")); } // need the project and contact to build the link between contact and project String projectId = StandardCode.getInstance().getCookie("projectAddId", request.getCookies()); Project p = ProjectService.getInstance().getSingleProject(Integer.valueOf(projectId)); ClientContact cc = ClientService.getInstance().getSingleClientContact(Integer.valueOf(contactId)); // insert into db, building link between contact and project ProjectService.getInstance().linkProjectClientContact(p, cc); // Forward control to the specified success URI return (mapping.findForward("Success")); }
@RequestMapping(value = "/api/client/{client}/summarystate", method = RequestMethod.GET) public @ResponseBody SummaryState getSummaryState(@PathVariable String client) throws Exception { Client cl = clientService.get(client); SummaryState summaryState = new SummaryState(); List<SalesItem> items = itemService.getItemsForClient(cl.getId()); summaryState.itemHash = HashUtil.getHash(items); List<SalesCategory> cats = categoryService.getAllCategoriesForClient(cl.getId()); summaryState.categoryHash = HashUtil.getHash(cats); List<SalesCategoryGroup> grps = categoryService.getGroupForClient(cl.getId()); summaryState.categoryGroupHash = HashUtil.getHash(grps); List<SalesItemOption> opts = optionService.getOptionsForClient(cl.getId()); summaryState.optionsHash = HashUtil.getHash(opts); List<SalesItemOptions> optGrp = optionService.getOptionGroupsForClient(cl.getId()); summaryState.optionGroupHash = HashUtil.getHash(optGrp); List<User> users = userService.findAllUsersForClient(cl.getId()); summaryState.userHash = HashUtil.getHash(users); try { log.debug("items", new ObjectMapper().writeValueAsString(items)); log.debug("cats", new ObjectMapper().writeValueAsString(cats)); log.debug("grps", new ObjectMapper().writeValueAsString(grps)); log.debug("opts", new ObjectMapper().writeValueAsString(opts)); log.debug("optGrp", new ObjectMapper().writeValueAsString(optGrp)); log.debug("user", new ObjectMapper().writeValueAsString(users)); } catch (Exception e) { log.debug("Error getting state", e); } return summaryState; }
public void testQuickServerBasic() { try { assertEquals(0, TestEventHandler.getGotConnectedFlag()); assertEquals(0, TestEventHandler.getClosingConnectionFlag()); assertEquals(0, TestEventHandler.getLostConnectionFlag()); assertEquals(0, TestCommandHandler.getHandleCommandFlag()); client.connect(host, port); sleep(50); assertEquals(1, TestEventHandler.getGotConnectedFlag()); System.out.println("GotConnected Pass"); client.sendString("test1"); sleep(50); assertEquals(1, TestCommandHandler.getHandleCommandFlag()); assertEquals("test1", TestCommandHandler.getRequest()); System.out.println("HandleCommand 1 Pass"); TestCommandHandler.setResponse("junit"); client.sendString("test2"); sleep(50); assertEquals(2, TestCommandHandler.getHandleCommandFlag()); assertEquals("test2", TestCommandHandler.getRequest()); assertEquals("junit", client.readString()); System.out.println("HandleCommand 2 Pass"); TestCommandHandler.setResponse("quit"); client.sendString("test3"); sleep(50); assertEquals(3, TestCommandHandler.getHandleCommandFlag()); assertEquals(1, TestEventHandler.getClosingConnectionFlag()); System.out.println("ClosingConnection Pass"); sleep(100); assertTrue(client.readString() == null); System.out.println("isConnected Pass"); client.close(); } catch (Exception e) { fail("Exception: " + e); } }
@RequestMapping(value = "/veract/{cid}", method = RequestMethod.GET) public String getVerActP( ModelMap model, @PathVariable int cid, @RequestParam(required = false, defaultValue = "") String dateFrom, @RequestParam(required = false, defaultValue = "") String dateTo, @RequestParam(required = false, defaultValue = "bank") String paymentType) { Client client = clientService.getClientById(cid); Date dFrom; Date dTo; List<Payment> payments; SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); if (!dateFrom.equals("") && !dateTo.equals("")) { try { dFrom = sdf.parse(dateFrom); dTo = sdf.parse(dateTo); payments = reportService.listVerAct(client, dFrom, dTo, paymentType); model.addAttribute("startDate", dFrom); model.addAttribute("endDate", dTo); model.addAttribute("myCompany", myCompanyService.getMyCompanyById(1)); if (payments.size() > 0) { model.addAttribute("payments", payments); } else { model.addAttribute("message", "Нет информации для отображения по выбранному периоду!"); } } catch (ParseException e) { e.printStackTrace(); model.addAttribute("message", "error parsing!"); } } model.addAttribute("client", client); return "/auth/payment/paymentveract"; }
public void update() { service.update(this.client); }
public Client saveClient(Client entity) { return clientService.saveClient(entity); }
public Client findClient(long clientId) { return clientService.findClient(clientId); }
public void deleteClient(long clientId) { clientService.deleteClient(clientId); }