Advertisement
Guest User

Untitled

a guest
May 27th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.07 KB | None | 0 0
  1.     /**
  2.      * Testmethode fuer createBestellung
  3.      *
  4.      * @throws KundeNotFoundException
  5.      * @throws BestellungDuplikatException
  6.      * @throws BestellungValidationException
  7.      * @throws ArtikelNotFoundException
  8.      * @throws InvalidKundeIdException
  9.      * @return void
  10.      */
  11.     @SuppressWarnings("unchecked")  // wegen anyOf()
  12.     @Test
  13.     public void createBestellung() throws KundeNotFoundException, BestellungDuplikatException, BestellungValidationException, ArtikelNotFoundException, InvalidKundeIdException {
  14.        
  15.         /**
  16.          * Konstantenzuweisungen
  17.          */
  18.         final Long kundeId = KUNDE_ID_VORHANDEN;
  19.         final Date datum = DATUM_BESTELLUNG_NEU;
  20.         final Long artikel1Id = ARTIKEL_1_ID;
  21.         final short artikel1Anzahl = ARTIKEL_1_ANZAHL;
  22.         final Long artikel2Id = ARTIKEL_2_ID;
  23.         final short artikel2Anzahl = ARTIKEL_2_ANZAHL;
  24.         final Long bbpId = BESTELLPOSITION_ID;
  25.         final int anzahl = ANZAHL;
  26.        
  27.         Bestellung bestellung = new Bestellung();
  28.         final List<Bestellposition> bestellpositionen = new ArrayList<Bestellposition>();
  29.         bestellung.setBestellposition(bestellpositionen);
  30.        
  31.         Artikel artikel = av.findArtikelById(artikel1Id);
  32.         Bestellposition bpos = new Bestellposition(bbpId, artikel, bestellung, anzahl);
  33.         bpos.setAnzahl(artikel1Anzahl);
  34.         bestellung.getBestellposition().add(bpos);
  35.         bpos.setBestellung(bestellung);
  36.        
  37.         artikel = av.findArtikelById(artikel2Id);
  38.         bpos = new Bestellposition(bbpId, artikel, bestellung, anzahl);
  39.         bpos.setAnzahl(artikel2Anzahl);
  40.         bestellung.getBestellposition().add(bpos);
  41.         bpos.setBestellung(bestellung);
  42.        
  43.         bestellung.setDatum(datum);
  44.        
  45.         Kunde kunde = kv.findKundeByIdMitBestellungen(kundeId, LOCALE);
  46.         bestellung.setKunde(kunde);
  47.         kunde.getBestellungen().add(bestellung);
  48.        
  49.         bestellung = bv.createBestellung(bestellung, Locale.getDefault(), false);
  50.         assertThat(bestellung.getBestellposition().size(), is(2));
  51.         for (Bestellposition bp: bestellung.getBestellposition()) {
  52.             assertThat(bp.getArtikel().getId(), anyOf(is(artikel1Id), is(artikel2Id)));
  53.         }
  54.        
  55.         kunde = bestellung.getKunde();
  56.         assertThat(kunde.getId(), is(kundeId));
  57.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement