public Collection<Order> findAllByClerk() { Collection<Order> result; Clerk clerk; clerk = clerkService.findByprincipal(); Assert.notNull(clerk); result = orderRepository.findAllByClerkId(clerk.getId()); return result; }
@Test public void testClerkServedLessOrders1() { System.out.println("ClerkServiceTest - testClerkServedLessOrders1 - StartPoint"); Collection<Clerk> all; authenticate("admin"); all = clerkService.findClerkServedLessOrders(); for (Clerk c : all) { System.out.println(c.getName() + " " + c.getSurname()); } authenticate(null); System.out.println("ClerkServiceTest - testClerkServedLessOrders1 - FinishPoint"); }
// ref: 18.3 public void assignToClerkManual(Clerk clerk, Order order) { Assert.notNull(clerk); Assert.isTrue(clerk.getId() != 0); Assert.notNull(order); Assert.isTrue(order.getId() != 0); Assert.isNull(order.getClerk()); order.setClerk(clerk); this.save(order); }
// Test --------------------------------------- @Test public void testCreate1() { System.out.println("Requisito 17.1 - Register a new clerk to the system."); System.out.println("ClerkServiceTest - testClerk1 - StartPoint"); Clerk result; Collection<Clerk> all; UserAccount userAccount; Collection<Message> received; Collection<Message> sent; Collection<Order> orders; received = new ArrayList<Message>(); sent = new ArrayList<Message>(); orders = new ArrayList<Order>(); authenticate("admin"); all = clerkService.findAll(); System.out.println("Lista de Clerks antes de la creación de otro"); for (Clerk c : all) { System.out.println(c.getName()); } result = clerkService.create(); userAccount = result.getUserAccount(); result.setName("Manuel"); result.setEmail("*****@*****.**"); result.setPhone("666123123"); result.setSurname("García"); userAccount.setUsername("Clerk99"); userAccount.setPassword("Clerk99"); result.setUserAccount(userAccount); result.setReceived(received); result.setSent(sent); result.setOrders(orders); clerkService.save(result); all = clerkService.findAll(); System.out.println("Lista de Clerks después de la creación de otro"); for (Clerk c : all) { System.out.println(c.getName()); } authenticate(null); System.out.println("ClerkServiceTest - testClerk1 - FinishPoint"); }