我正在尝试使用Junit编写测试方法:我可以一起使用assertNull和assertNotNull语句吗?

问题描述

 'I'm trying to write a test method with Junit: Can I use assertNull and assertNotNull statements together?  I may have used it incorrectly because I am trying to learn.

我可能也误解了单元测试逻辑。你能帮我吗?'

   ' My codes:'
     public static TtVaeTarifeTipi getMaxDownloadVeUploadaSahipTtVaeTarifeTipi(List<TtVaeTarifeTipi> ttVaeTarifeTipiListe) {
            if (ttVaeTarifeTipiListe.isEmpty() || ttVaeTarifeTipiListe == null) {
                return null;
            }
            else{
                Map<Integer,List<TtVaeTarifeTipi>> downloadaGoreGruplanmisTtVaeTarifeTipleriMap = ttVaeTarifeTipiListe.stream().collect(groupingBy(t -> t.getTtVaePaket().getDownload()));
                Integer maxHizDegeri = downloadaGoreGruplanmisTtVaeTarifeTipleriMap.entrySet().stream().max(Map.Entry.comparingByKey()).get().getKey();
                List<TtVaeTarifeTipi> maxDownloadaSahipTtVaeTarifeTipleri = downloadaGoreGruplanmisTtVaeTarifeTipleriMap.get(maxHizDegeri);
                return maxDownloadaSahipTtVaeTarifeTipleri.stream().max(Comparator.comparing(t -> t.getTtVaePaket().getUpload())).get();
    
            }
        }
   'and test codes:
      @Test
        @Transactional
        public void testMaxDownloadVeUploadaSahipTtVaeTarifeTipi() {
            List<TtVaeTarifeTipi> ttVaeTarifeTipiListe = getornekTtVaeTarifeTiplieri();
            if (ttVaeTarifeTipiListe.isEmpty() || ttVaeTarifeTipiListe == null) {
                Assert.assertNull(TtVaeUtils.getMaxDownloadVeUploadaSahipTtVaeTarifeTipi(ttVaeTarifeTipiListe));
            } else {
                Assert.assertNotNull(TtVaeUtils.getMaxDownloadVeUploadaSahipTtVaeTarifeTipi(ttVaeTarifeTipiListe));
            }
        }

我可以一起使用assertNull和assertNotNull语句吗?我可能没有正确使用它,因为我正在尝试学习。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)