Package com.example.customerservice

Examples of com.example.customerservice.Customer


        Assert.assertEquals(100000.0, firstCustomer.getRevenue(), 0.00001);
    }

    @Test
    public void testRoundTripSaveCustomer() throws Exception {
        Customer testCustomer = new Customer();
        testCustomer.setName("testName");
        SaveCustomer request = new SaveCustomer();
        request.setCustomer(testCustomer);
        customerService.saveCustomer(request);
        Customer customer2 = serverBean.getLastSavedCustomer();
        Assert.assertEquals("testName", customer2.getName());
    }
View Full Code Here


            NoSuchCustomer noSuchCustomer = new NoSuchCustomer();
            noSuchCustomer.setCustomerId(request.getName());
            throw new NoSuchCustomerException("Customer not found", noSuchCustomer);
        }
        GetCustomersByNameResponse response = new GetCustomersByNameResponse();
        Customer customer = new Customer();
        customer.setName(request.getName());
        customer.setRevenue(100000);
        response.getReturn().add(customer);
        return response;
    }
View Full Code Here

    /**
     * This method is to test a call without input parameter
     */
    public GetAllCustomersResponse getAllCustomers() {
        GetAllCustomersResponse response = new GetAllCustomersResponse();
        Customer customer = new Customer();
        customer.setName("Smith");
        customer.setRevenue(100000);
        response.getReturn().add(customer);
        return response;
    }
View Full Code Here

    /**
     * This method is to test a call without input parameter
     */
    public GetAllAmericanCustomersResponse getAllAmericanCustomers() {
        GetAllAmericanCustomersResponse response = new GetAllAmericanCustomersResponse();
        Customer customer = new Customer();
        customer.setName("Schmitz");
        customer.setRevenue(100000);
        response.getReturn().add(customer);
        return response;
    }
View Full Code Here

                                              noSuchCustomer);
        }

        List<Customer> customers = new ArrayList<Customer>();
        for (int c = 0; c < 2; c++) {
            Customer cust = new Customer();
            cust.setName(name);
            cust.getAddress().add("Pine Street 200");
            Date bDate = new GregorianCalendar(2009, 01, 01).getTime();
            cust.setBirthDate(bDate);
            cust.setNumOrders(1);
            cust.setRevenue(1000);
            cust.setTest(new BigDecimal(1.5));
            cust.setType(CustomerType.BUSINESS);
            customers.add(cust);
        }

        return customers;
    }
View Full Code Here

                                              noSuchCustomer);
        }

        List<Customer> customers = new ArrayList<Customer>();
        for (int c = 0; c < 2; c++) {
            Customer cust = new Customer();
            cust.setName(name);
            cust.getAddress().add("Pine Street 200");
            cust.setNumOrders(1);
            cust.setRevenue(10000);
            cust.setTest(new BigDecimal(1.5));
            cust.setType(CustomerType.BUSINESS);
            customers.add(cust);
        }

        return customers;
    }
View Full Code Here

    public List<Customer> getCustomersByName(String name) throws NoSuchCustomerException {
       
        // The authenticated users can be retrieved from the spring security context at any time
      String userName = SecurityContextHolder.getContext().getAuthentication().getName();
        System.out.println("Customers matching name " + name + " are read by user " + userName);
        Customer customer = createDummyCustomer(name);
        return Collections.singletonList(customer);
    }
View Full Code Here

        Customer customer = createDummyCustomer(name);
        return Collections.singletonList(customer);
    }

  private Customer createDummyCustomer(String name) {
    Customer customer = new Customer();
        customer.setName(name);
        customer.setNumOrders(10);
        customer.setRevenue(10.500d);
        customer.setType(CustomerType.BUSINESS);
    return customer;
  }
View Full Code Here

        // Bob should be able to read customers but not to update
        CredentialsInjector.inject(customerService, "bob", "bobspassword");
        try {
            List<Customer> customersByName = customerService.getCustomersByName("Fred");
            Customer customer = customersByName.get(0);
            logger.info("Bob was able to load the customer " + customer.getName());
        } catch (Exception e) {
            Assert.fail("Bob should be allowed to read customers");
        }
        CredentialsInjector.inject(customerService, "bob", "bobspassword");
        try {
            Customer customer = new Customer();
            customer.setName("Fred");
            customerService.updateCustomer(customer);
            Assert.fail("Bob should not be allowed to update a customer");
        } catch (Exception e) {
            logger.info("Bob's request was correctly denied. " + getMessage(e));
        }

        // Jim should be able to read and update customers
        CredentialsInjector.inject(customerService, "jim", "jimspassword");
        try {
            List<Customer> customersByName = customerService.getCustomersByName("Fred");
            Customer customer = customersByName.get(0);
            logger.info("Jim was able to load the customer " + customer.getName());
        } catch (Exception e) {
            Assert.fail("Jim should be allowed to read customers");
        }
        CredentialsInjector.inject(customerService, "jim", "jimspassword");
        try {
            Customer customer = new Customer();
            customer.setName("Fred");
            customerService.updateCustomer(customer);
            logger.info("Jim was able to update the customer");
        } catch (Exception e) {
            Assert.fail("Jim should be allowed to update a customer");
        }
View Full Code Here

                                              noSuchCustomer);
        }

        List<Customer> customers = new ArrayList<Customer>();
        for (int c = 0; c < 2; c++) {
            Customer cust = new Customer();
            cust.setName(name);
            cust.getAddress().add("Pine Street 200");
            Date bDate = new GregorianCalendar(2009, 01, 01).getTime();
            cust.setBirthDate(bDate);
            cust.setNumOrders(1);
            cust.setRevenue(1000);
            cust.setTest(new BigDecimal(1.5));
            cust.setType(CustomerType.BUSINESS);
            customers.add(cust);
        }

        return customers;
    }
View Full Code Here

TOP

Related Classes of com.example.customerservice.Customer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.