}
public void testSearchAdmin() throws Throwable {
String username = "supervisorCoach";// User with jpwwtAdmin permission
assertEquals(0, this._ticketManager.searchTicketIds(null).size());
Ticket t1 = this._helper.createTicket(null, new Date(), "nome1", "cognome1", "codFisc1", "comune1",
"localita1", "ind1", "indirizzo1", "num1", "telefono1", "email1@email.itte", "message1",
username, 0, 1, 0, "pageManagerCustomers", "pageManager", Ticket.STATES_OPENED, null, false);
this._ticketManager.addTicket(t1);
Ticket t2 = this._helper.createTicket(null, new Date(), null, "message2", username, 1,
1, "mainEditor", null, Ticket.STATES_ASSIGNED, new Date(), false);
this._ticketManager.addTicket(t2);
Ticket t3 = this._helper.createTicket(null, new Date(), null, "message3", null, 2,
2, "editorCustomers", null, Ticket.STATES_DISPATCHED, null, true);
this._ticketManager.addTicket(t3);
Ticket t4 = this._helper.createTicket(null, new Date(), null, null, "pageManagerCustomers", 1,
0, "editorCustomers", null, Ticket.STATES_CLOSED, new Date(), false);
this._ticketManager.addTicket(t4);
Map<String, String> params = this.prepareParams("message2", "", "", "", "", "", "", "");
String result = this.executeSearch(username, params); // message = 'message2'
assertEquals(Action.SUCCESS, result);
List<String> ticketIds = ((AbstractTicketFinderAction) this.getAction()).getTicketIds();
this.verifyTicketIds(new String[] { t2.getCode() }, ticketIds);
params.put("message", "ess");
result = this.executeSearch(username, params); // message = 'ess'
assertEquals(Action.SUCCESS, result);
ticketIds = ((AbstractTicketFinderAction) this.getAction()).getTicketIds();
this.verifyTicketIds(new String[] { t1.getCode(), t2.getCode(), t3.getCode() }, ticketIds);
params.put("priority", "0");
params.remove("message");
result = this.executeSearch(username, params); // priority = '0'
assertEquals(Action.SUCCESS, result);
ticketIds = ((AbstractTicketFinderAction) this.getAction()).getTicketIds();
this.verifyTicketIds(new String[] { t1.getCode(), t4.getCode() }, ticketIds);
params.put("userInterventionType", "0");
params.put("assignedInterventionType", "1");
result = this.executeSearch(username, params); // priority = '0', userInterventionType = '0', assignedInterventionType = '1'
assertEquals(Action.SUCCESS, result);
ticketIds = ((AbstractTicketFinderAction) this.getAction()).getTicketIds();
this.verifyTicketIds(new String[] { t1.getCode() }, ticketIds);
params.put("userInterventionType", "1");
params.put("assignedInterventionType", "");
result = this.executeSearch(username, params); // priority = '0', userInterventionType = '1'
assertEquals(Action.SUCCESS, result);
ticketIds = ((AbstractTicketFinderAction) this.getAction()).getTicketIds();
this.verifyTicketIds(new String[] { t4.getCode() }, ticketIds);
params.put("priority", "");
result = this.executeSearch(username, params); // userInterventionType = '1'
assertEquals(Action.SUCCESS, result);
ticketIds = ((AbstractTicketFinderAction) this.getAction()).getTicketIds();
this.verifyTicketIds(new String[] { t2.getCode(), t4.getCode() }, ticketIds);
params.put("status", String.valueOf(Ticket.STATES_DISPATCHED));
result = this.executeSearch(username, params); // userInterventionType = '1', status = 'DISPATCHED'
assertEquals(Action.SUCCESS, result);
ticketIds = ((AbstractTicketFinderAction) this.getAction()).getTicketIds();
this.verifyTicketIds(new String[] { }, ticketIds);
params.put("userInterventionType", "");
result = this.executeSearch(username, params); // status = 'DISPATCHED'
assertEquals(Action.SUCCESS, result);
ticketIds = ((AbstractTicketFinderAction) this.getAction()).getTicketIds();
this.verifyTicketIds(new String[] { t3.getCode() }, ticketIds);
params.put("status", "");
params.put("userInterventionType", "");
params.put("resolved", "1");
result = this.executeSearch(username, params); // resolved = 'true'
assertEquals(Action.SUCCESS, result);
ticketIds = ((AbstractTicketFinderAction) this.getAction()).getTicketIds();
this.verifyTicketIds(new String[] { t3.getCode() }, ticketIds);
params.put("resolved", "0");
result = this.executeSearch(username, params); // resolved = 'false'
assertEquals(Action.SUCCESS, result);
ticketIds = ((AbstractTicketFinderAction) this.getAction()).getTicketIds();
this.verifyTicketIds(new String[] { t1.getCode(), t2.getCode(), t4.getCode() }, ticketIds);
params.put("resolved", "");
result = this.executeSearch(username, params); // resolved = ''
assertEquals(Action.SUCCESS, result);
ticketIds = ((AbstractTicketFinderAction) this.getAction()).getTicketIds();
this.verifyTicketIds(new String[] { t1.getCode(), t2.getCode(), t3.getCode(), t4.getCode() }, ticketIds);
}