Esempio n. 1
0
  @SuppressWarnings("deprecation")
  @Before
  public void setUp() throws Exception {
    System.setProperty("java.security.policy", "polis.policy");
    if (System.getSecurityManager() == null) {
      System.setSecurityManager(new SecurityManager());
    }
    try {
      Registry registry = LocateRegistry.getRegistry("localhost");
      articoloFacade = (IArticoloMenuFacade) registry.lookup("ArticoloFacade");
      ordinazioneFacade = (IOrdinazioneFacade) registry.lookup("OrdineFacade");
      tavoloFacade = (ITavoloFacade) registry.lookup("TavoloFacade");
      userFacade = (IUserFacade) registry.lookup("UserFacade");
      ristoranteFacade = (IRistoranteFacade) registry.lookup("RistoranteFacade");
    } catch (Exception e) {
      System.err.println("Exception to obtain the reference to the remote object: " + e);
    }

    user = userFacade.login(Ruolo.TEST, "test");

    tavolo = new Tavolo();
    tavolo.setNumeroPosti(4);
    tavolo.setAttivo(true);
    tavolo.setOccupato(false);
    tavolo.setRiferimento("Tavolo Test");

    ristorante = new Ristorante();
    ristorante.setRagioneSociale("Ristorante Test");
    ristorante.setPartitaIva("01234567891");

    Indirizzo indirizzo = new Indirizzo();
    indirizzo.setVia("via Roma");
    indirizzo.setCivico("24 A");
    indirizzo.setCap("83100");
    indirizzo.setProvincia("Av");
    indirizzo.setCitta("Avellino");
    ristorante.setIndirizzo(indirizzo);

    ristorante = ristoranteFacade.inserisciRistorante(user, ristorante);
    tavolo.setRistorante(ristorante);

    tavolo = tavoloFacade.inserisciTavolo(user, tavolo);

    pietanza = new Pietanza();
    pietanza = new Pietanza();
    pietanza.setNome("BEVANDA TEST");
    pietanza.setTipoPietanza(TipoPietanza.PRIMO_PIATTO.ordinal());
    pietanza = articoloFacade.inserisciPietanzaMenu(user, pietanza);

    ordinazione = new Ordinazione();
    ordinazione.setCoperti(4);
    ordinazione.setTerminato(true);
    ordinazione.setTavolo(tavolo);
    ordinazione.setData(new Date(109, 5, 30));

    ordinazione = ordinazioneFacade.inserisciOrdinazione(user, ordinazione);
  }
Esempio n. 2
0
  @Test
  public void testRimozioneOrdinazione() throws Exception {
    User user_test = null;
    try {
      user_test = userFacade.login(Ruolo.CAMERIERE, "1234");
    } catch (RemoteException e) {
      fail("RemoteException");
    }

    boolean verifica = false;
    try {
      verifica = ordinazioneFacade.rimuoviOrdinazione(user_test, ordinazione.getId(), false);
    } catch (Exception e) {
      verifica = false;
    }

    try {
      userFacade.logout(user_test);
    } catch (RemoteException e) {
      fail("RemoteException");
    }
    assertTrue(verifica);
  }
Esempio n. 3
0
  @Test
  public void testSelezioneOrdinazione() throws Exception {
    User user_test = null;
    try {
      user_test = userFacade.login(Ruolo.AMMINISTRATORE, "123456");
    } catch (RemoteException e) {
      fail("RemoteException");
    }

    Ordinazione ordinazione2 = null;
    try {
      ordinazione2 = ordinazioneFacade.selezionaOrdinazionePerId(user_test, null);
    } catch (Exception e) {
      ordinazione2 = null;
    }

    try {
      userFacade.logout(user_test);
    } catch (RemoteException e) {
      fail("RemoteException");
    }

    assertNull(ordinazione2);
  }