Ejemplo n.º 1
0
  @Before
  public void setup() {
    user = new User("test-user", "pass");
    user.setEmail("test@localhost");
    user = userRepository.save(user);

    organization = new Organization("test-organization", user);
    organization = organizationRepository.save(organization);

    category = new Category();
    category.setOrganization(organization);
    category.setName("Category 1");
    category.setDescription("Category description");
    category = categoryRepository.save(category);

    topic = new Topic();
    topic.setCategory(category);
    topic.setName("Topic 1");
    topic.setDescription("Topic description");
    topic = topicRepository.save(topic);

    cardDetails1 = new CardDetails();
    cardDetails1.setCategory(category);
    cardDetails1.setCreator(user);
    cardDetails1.setText("Card 1");
    cardDetails1 = cardDetailsRepository.save(cardDetails1);

    cardDetails2 = new CardDetails();
    cardDetails2.setCategory(category);
    cardDetails2.setCreator(user);
    cardDetails2.setText("Card 2");
    cardDetails2 = cardDetailsRepository.save(cardDetails2);

    cardDetails3 = new CardDetails();
    cardDetails3.setCategory(category);
    cardDetails3.setCreator(user);
    cardDetails3.setText("Card 3");
    cardDetails3 = cardDetailsRepository.save(cardDetails3);

    cardDetails4 = new CardDetails();
    cardDetails4.setCategory(category);
    cardDetails4.setCreator(user);
    cardDetails4.setText("Card 4");
    cardDetails4 = cardDetailsRepository.save(cardDetails4);

    cardDetails5 = new CardDetails();
    cardDetails5.setCategory(category);
    cardDetails5.setCreator(user);
    cardDetails5.setText("Card 5");
    cardDetails5 = cardDetailsRepository.save(cardDetails5);

    category.setCards(new HashSet<>());
    category.getCards().add(cardDetails1);
    category.getCards().add(cardDetails2);
    category.getCards().add(cardDetails3);
    category.getCards().add(cardDetails4);
    category.getCards().add(cardDetails5);

    category = categoryRepository.save(category);
  }
Ejemplo n.º 2
0
  @Test
  public void testAddSessionToTopic() {
    cardService.addCardDetailsToTopic(topic, cardDetails1);
    cardService.addCardDetailsToTopic(topic, cardDetails2);
    cardService.addCardDetailsToTopic(topic, cardDetails3);
    cardService.addCardDetailsToTopic(topic, cardDetails4);
    cardService.addCardDetailsToTopic(topic, cardDetails5);

    Session session = new SynchronousSession();
    session.setOrganizer(user);
    session.setCategory(category);
    session.setTopic(this.topic);

    Session savedSession = sessionService.addSession(session);
    assertEquals(savedSession.getTopic().getName(), topic.getName());
    assertEquals(savedSession.getOrganizer().getUserId(), this.user.getUserId());
  }