Example #1
0
  @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");
      userFacade = (IUserFacade) registry.lookup("UserFacade");
    } catch (Exception e) {
      System.err.println("Exception to obtain the reference to the remote object: " + e);
      fail("Exception");
    }

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

    bevanda = new Bevanda();
    bevanda.setCapacita(1000F);
    bevanda.setNome("BEVANDA TEST");
    bevanda.setTipoArticolo("Bevanda");
    bevanda.setTipoPietanza(TipoPietanza.BEVANDA.ordinal());

    bevanda = articoloFacade.inserisciBevandaMenu(user, bevanda);

    articoloFacade.inserisciBevandaMagazzino(user, bevanda.getId(), 1L, 10000);
  }
Example #2
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");
      userFacade = (IUserFacade) registry.lookup("UserFacade");
    } catch (Exception e) {
      System.err.println("Exception to obtain the reference to the remote object: " + e);
      fail("Exception");
    }

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

    ingrediente.setNome("Test Ingrediente");
    ingrediente.setScadenza(new Date(109, 4, 31));
    ingrediente.setVariante(true);

    ingrediente = articoloFacade.inserisciIngrediente(user, ingrediente);

    pietanza.setNome("Pietanza Test");
    pietanza.setTipoPietanza(TipoPietanza.PRIMO_PIATTO.ordinal());

    pietanza = articoloFacade.inserisciPietanzaMenu(user, pietanza);
  }
Example #3
0
  @SuppressWarnings("deprecation")
  @Test
  public void testUpdateIngrediente() {
    User user_test = null;
    try {
      user_test = userFacade.login(Ruolo.CAMERIERE, "1234");
    } catch (RemoteException e) {
      user_test = null;
    }

    Ingrediente ingrediente_test = ingrediente;
    ingrediente_test.setNome("INGREDIENTE TEST");
    ingrediente_test.setScadenza(new Date(109, 4, 31));
    ingrediente_test.setVariante(true);
    boolean test_return = false;
    try {
      test_return = articoloFacade.updateIngrediente(user_test, ingrediente_test);
    } catch (AccessControlException e) {
      test_return = false;
    } catch (RemoteException e) {
      fail("RemoteException");
    }

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

    assertFalse(test_return);
  }
Example #4
0
  @Test
  public void testInserimentoIngredientePietanza() {
    User user_test = null;
    try {
      user_test = userFacade.login(Ruolo.CAMERIERE, "1234");
    } catch (RemoteException e) {
      fail("RemoteException");
    }

    ingredientePietanza = new IngredientePietanza();
    ingredientePietanza.setQuantita(5);
    ingredientePietanza.setIngrediente(ingrediente);
    ingredientePietanza.setArticolo(pietanza);

    try {
      ingredientePietanza =
          articoloFacade.inserisciIngredientePietanza(user_test, ingredientePietanza);
    } catch (AccessControlException e) {
      ingredientePietanza = null;
    } catch (RemoteException e) {
      fail("RemoteException");
    }

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

    assertNull(ingredientePietanza);
  }
Example #5
0
  @Test
  public void testInserimentoIngredientiPietanza() {
    User user_test = null;
    try {
      user_test = userFacade.login(Ruolo.CUOCO, "12345");
    } catch (RemoteException e) {
      fail("RemoteException");
    }

    HashSet<IngredientePietanza> ingredienti = new HashSet<IngredientePietanza>();

    try {
      ingredienti = articoloFacade.inserisciIngredientiPietanze(user_test, ingredienti);
    } catch (AccessControlException e) {
      ingredienti = null;
    } catch (RemoteException e) {
      fail("RemoteException");
    }

    if (ingredienti.size() == 0) ingredienti = null;

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

    assertNull(ingredienti);
  }
Example #6
0
  @Test
  public void testUpdatePietanza() {
    User user_test = null;
    try {
      user_test = userFacade.login(Ruolo.CUOCO, "12345");
    } catch (RemoteException e) {
      fail("RemoteException");
    }

    Pietanza pietanza_test = pietanza;
    pietanza_test.setNome(null);
    pietanza_test.setTipoPietanza(TipoPietanza.PRIMO_PIATTO.ordinal());
    boolean test_return = false;
    try {
      test_return = articoloFacade.updatePietanza(user_test, pietanza_test);
    } catch (AccessControlException e) {
      test_return = false;
    } catch (RemoteException e) {
      fail("RemoteException");
    }

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

    assertFalse(test_return);
  }
Example #7
0
  @Test
  public void testRimozioneIngrediente() {
    User user1 = null;
    try {
      user1 = userFacade.login(Ruolo.AMMINISTRATORE, "123456");
    } catch (RemoteException e1) {
      fail("RemoteException");
    }

    boolean ingredienteAttuale = false;
    try {
      ingredienteAttuale = articoloFacade.rimuoviIngrediente(user1, ingrediente.getId());
    } catch (AccessControlException e) {
      ingredienteAttuale = false;
    } catch (RemoteException e) {
      fail("RemoteException");
    }

    if (user1 != null) {
      try {
        userFacade.logout(user1);
      } catch (RemoteException e) {
        fail("RemoteException");
      }
    }

    Assert.assertFalse(ingredienteAttuale);
  }
Example #8
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"); // CONTROLLARE
      userFacade = (IUserFacade) registry.lookup("UserFacade");
    } catch (Exception e) {
      System.err.println("Exception to obtain the reference to the remote object: " + e);
      fail("Exception");
    }

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

    ingrediente = new Ingrediente();
    ingrediente.setDescrizione("Ingrediente di test");
    ingrediente.setId((long) 1000000L);
    ingrediente.setNome("Ingrediente di Test");
    ingrediente.setTipoIngrediente("IngredienteLungaConservazione");
    ingrediente.setScadenza(new Date(109, 1, 21));
    ingrediente.setUnitaMisura("g");
    ingrediente.setVariante(true);

    ingrediente = articoloFacade.inserisciIngrediente(user, ingrediente);
  }
Example #9
0
 @After
 public void tearDown() throws Exception {
   articoloFacade.rimuoviPietanzaMenu(user, pietanza.getId());
   tavoloFacade.rimuoviTavolo(user, tavolo.getId());
   ristoranteFacade.rimuoviRistorante(user, ristorante.getRagioneSociale());
   userFacade.logout(user);
 }
Example #10
0
  @Test
  public void testValutazioneDisponibilitaBevanda() {
    User user_test = null;
    try {
      user_test = userFacade.login(Ruolo.AMMINISTRATORE, "123456");
    } catch (RemoteException e) {
      fail("RemoteException");
    }

    int test_return = 0;
    try {
      test_return = articoloFacade.selezionaDisponibilitaBevanda(user_test, bevanda.getId());
    } catch (AccessControlException e) {
      test_return = 0;
    } catch (RemoteException e) {
      fail("RemoteException");
    }

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

    assertFalse(test_return > 0);
  }
Example #11
0
  @Test
  public void testInserimentoBevandaMenu() {
    User user_test = null;
    try {
      user_test = userFacade.login(Ruolo.AMMINISTRATORE, "123456");
    } catch (RemoteException e) {
      fail("RemoteException");
    }

    bevanda = new Bevanda();
    bevanda.setCapacita(1000F);
    bevanda.setNome("BEVNDA TEST");
    bevanda.setTipoArticolo("BEVANDA");
    bevanda.setTipoPietanza(TipoPietanza.BEVANDA.ordinal());

    try {
      bevanda = articoloFacade.inserisciBevandaMenu(user_test, bevanda);
    } catch (AccessControlException e) {
      bevanda = null;
    } catch (RemoteException e) {
      fail("RemoteException");
    }

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

    assertNull(bevanda);
  }
Example #12
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);
  }
Example #13
0
  @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");
      userFacade = (IUserFacade) registry.lookup("UserFacade");
    } catch (Exception e) {
      System.err.println("Exception to obtain the reference to the remote object: " + e);
      fail("Exception");
    }

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

    pietanza = new Pietanza();
    pietanza.setNome("PIETANZA TEST");
    pietanza.setTipoPietanza(TipoPietanza.PRIMO_PIATTO.ordinal());

    pietanza = articoloFacade.inserisciPietanzaMenu(user, pietanza);
  }
Example #14
0
 @After
 public void tearDown() throws Exception {
   articoloFacade.rimuoviIngrediente(user, ingrediente.getId());
   userFacade.logout(user);
 }
Example #15
0
 @After
 public void tearDown() throws Exception {
   articoloFacade.rimuoviPietanzaMenu(user, pietanza.getId());
   userFacade.logout(user);
 }
Example #16
0
 @After
 public void tearDown() throws Exception {
   articoloFacade.rimuoviBevandaMenu(user, bevanda.getId());
   userFacade.logout(user);
 }