コード例 #1
0
  @Test
  public void compareAndUpdateSportteryAllBeans_InsertOneBean_HistoryRepositoryShouldNotBeCalled() {

    List<SportteryAllEntity> list = new ArrayList<>();
    SportteryAllEntity sportteryAllEntity = new SportteryAllEntity();
    sportteryAllEntity.setMatchCode("1001");
    list.add(sportteryAllEntity);
    when(sportteryAllRepository.findByMatchCode(isA(String.class))).thenReturn(null);
    sportteryDao.compareAndUpdateSportteryAllBeans(list);
    verify(sportteryAllRepository).findByMatchCode(isA(String.class));
    verify(sportteryAllRepository).save(isA(SportteryAllEntity.class));
    verifyNoMoreInteractions(sportteryAllRepository);
  }
コード例 #2
0
  @Test
  public void compareAndUpdateBeans_InsertOneBean_HistoryRepositoryShouldNotBeCalled() {

    List<TCrawlerSporttery> list = new ArrayList<>();
    TCrawlerSporttery e = new TCrawlerSporttery();
    e.setCompetitionNum("1001");
    list.add(e);
    when(tCrawlerSportteryRepository.findByCompetitionNum(isA(String.class)))
        .thenAnswer(
            new Answer<TCrawlerSporttery>() {
              @Override
              public TCrawlerSporttery answer(InvocationOnMock invocation) throws Throwable {

                return null;
              }
            });
    sportteryDao.compareAndUpdateBeans(list);
    verify(tCrawlerSportteryRepository).findByCompetitionNum(isA(String.class));
    verify(tCrawlerSportteryRepository).save(isA(TCrawlerSporttery.class));
    verifyNoMoreInteractions(tCrawlerSportteryRepository);
  }