Exemplo n.º 1
0
  @WithMockUser(username = "******", password = "******", roles = "ADMIN")
  @Test
  public void testErrorThrownNoEvent() {
    Project project = projectService.read(1L);

    Sample sample = sampleService.read(1L);

    try {
      projectService.addSampleToProject(project, sample);
      fail("EntityExistsException should have been thrown");
    } catch (EntityExistsException ex) {
      // it's all good
    }

    Page<ProjectEvent> eventsForProject =
        projectEventService.getEventsForProject(project, new PageRequest(0, 10));

    assertEquals("No event should be created", 0, eventsForProject.getTotalElements());
  }
Exemplo n.º 2
0
  @WithMockUser(username = "******", password = "******", roles = "ADMIN")
  @Test
  public void testAddProjectSample() {
    Project project = projectService.read(1L);

    Sample sample = sampleService.read(2L);

    projectService.addSampleToProject(project, sample);

    Page<ProjectEvent> eventsForProject =
        projectEventService.getEventsForProject(project, new PageRequest(0, 10));

    assertEquals(1, eventsForProject.getTotalElements());
    ProjectEvent event = eventsForProject.iterator().next();

    assertTrue(event instanceof SampleAddedProjectEvent);
    SampleAddedProjectEvent userEvent = (SampleAddedProjectEvent) event;
    assertEquals(project, userEvent.getProject());
    assertEquals(sample, userEvent.getSample());
  }