Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Testmethode fuer createBestellung
- *
- * @throws KundeNotFoundException
- * @throws BestellungDuplikatException
- * @throws BestellungValidationException
- * @throws ArtikelNotFoundException
- * @throws InvalidKundeIdException
- * @return void
- */
- @SuppressWarnings("unchecked") // wegen anyOf()
- @Test
- public void createBestellung() throws KundeNotFoundException, BestellungDuplikatException, BestellungValidationException, ArtikelNotFoundException, InvalidKundeIdException {
- /**
- * Konstantenzuweisungen
- */
- final Long kundeId = KUNDE_ID_VORHANDEN;
- final Date datum = DATUM_BESTELLUNG_NEU;
- final Long artikel1Id = ARTIKEL_1_ID;
- final short artikel1Anzahl = ARTIKEL_1_ANZAHL;
- final Long artikel2Id = ARTIKEL_2_ID;
- final short artikel2Anzahl = ARTIKEL_2_ANZAHL;
- final Long bbpId = BESTELLPOSITION_ID;
- final int anzahl = ANZAHL;
- Bestellung bestellung = new Bestellung();
- final List<Bestellposition> bestellpositionen = new ArrayList<Bestellposition>();
- bestellung.setBestellposition(bestellpositionen);
- Artikel artikel = av.findArtikelById(artikel1Id);
- Bestellposition bpos = new Bestellposition(bbpId, artikel, bestellung, anzahl);
- bpos.setAnzahl(artikel1Anzahl);
- bestellung.getBestellposition().add(bpos);
- bpos.setBestellung(bestellung);
- artikel = av.findArtikelById(artikel2Id);
- bpos = new Bestellposition(bbpId, artikel, bestellung, anzahl);
- bpos.setAnzahl(artikel2Anzahl);
- bestellung.getBestellposition().add(bpos);
- bpos.setBestellung(bestellung);
- bestellung.setDatum(datum);
- Kunde kunde = kv.findKundeByIdMitBestellungen(kundeId, LOCALE);
- bestellung.setKunde(kunde);
- kunde.getBestellungen().add(bestellung);
- bestellung = bv.createBestellung(bestellung, Locale.getDefault(), false);
- assertThat(bestellung.getBestellposition().size(), is(2));
- for (Bestellposition bp: bestellung.getBestellposition()) {
- assertThat(bp.getArtikel().getId(), anyOf(is(artikel1Id), is(artikel2Id)));
- }
- kunde = bestellung.getKunde();
- assertThat(kunde.getId(), is(kundeId));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement