Пример #1
0
  @Test
  public void getAllByStatus_returns_all_analyses() {
    SampleItem matchingSampleItemWithATestSection =
        DBHelper.createAndSaveSampleItem(DBHelper.createAndSaveSample("12345"));
    Analysis firstMatchingAnalysis =
        DBHelper.createAndSaveAnalysis(
            matchingSampleItemWithATestSection,
            StatusOfSampleUtil.AnalysisStatus.TechnicalAcceptance,
            "Hematology",
            null,
            null);

    SampleItem matchingSampleItemWithADifferentTestSection =
        DBHelper.createAndSaveSampleItem(DBHelper.createAndSaveSample("123456"));
    Analysis secondMatchingAnalysis =
        DBHelper.createAndSaveAnalysis(
            matchingSampleItemWithADifferentTestSection,
            StatusOfSampleUtil.AnalysisStatus.NotTested,
            "Biochemistry",
            null,
            null);

    SampleItem nonMatchingSampleItemWithDifferentStatus =
        DBHelper.createAndSaveSampleItem(DBHelper.createAndSaveSample("1234567"));
    Analysis nonMatchingAnalysis =
        DBHelper.createAndSaveAnalysis(
            nonMatchingSampleItemWithDifferentStatus,
            StatusOfSampleUtil.AnalysisStatus.BiologistRejected,
            "Biochemistry",
            null,
            null);

    List<Analysis> actualAnalyses =
        new AnalysisDAOImpl()
            .getAllAnalysisByStatus(
                Arrays.asList(
                    StatusOfSampleUtil.AnalysisStatus.TechnicalAcceptance,
                    StatusOfSampleUtil.AnalysisStatus.NotTested));

    Assert.assertTrue(
        "should return analysis with matching analysis status",
        actualAnalyses.contains(firstMatchingAnalysis));
    Assert.assertTrue(
        "should return analysis with matching analysis status",
        actualAnalyses.contains(secondMatchingAnalysis));
    Assert.assertTrue(
        "should not return analysis with non matching analysis status",
        !actualAnalyses.contains(nonMatchingAnalysis));
  }
Пример #2
0
  @Test
  public void getAllByAccessionNumberAndStatus_does_not_return_non_matching_analysis_status() {
    String accessionNumber = "12345";
    StatusOfSampleUtil.AnalysisStatus nonMatchingStatus =
        StatusOfSampleUtil.AnalysisStatus.TechnicalAcceptance;
    Sample nonMatchingAccessionNumberSample = DBHelper.createAndSaveSample(accessionNumber);
    SampleItem nonMatchingSampleItem =
        DBHelper.createAndSaveSampleItem(nonMatchingAccessionNumberSample);
    DBHelper.createAndSaveAnalysis(
        nonMatchingSampleItem, nonMatchingStatus, "Hematology", null, null);

    List<Analysis> actualAnalyses =
        new AnalysisDAOImpl()
            .getAllAnalysisByAccessionNumberAndStatus(
                accessionNumber,
                Arrays.asList(StatusOfSampleUtil.AnalysisStatus.BiologistRejected));

    Assert.assertTrue(
        "should not return analysis with non matching analysis status", actualAnalyses.isEmpty());
  }
Пример #3
0
  @Test
  public void getAllByAccessionNumberAndStatus_returns_matching_analysis() {
    StatusOfSampleUtil.AnalysisStatus toBeValidatedAnalysisStatus =
        StatusOfSampleUtil.AnalysisStatus.TechnicalAcceptance;
    String accessionNumber = "12345";
    Sample startedSample = DBHelper.createAndSaveSample(accessionNumber);
    SampleItem enteredSampleItem = DBHelper.createAndSaveSampleItem(startedSample);

    DBHelper.createAndSaveAnalysis(
        enteredSampleItem, toBeValidatedAnalysisStatus, "Hematology", null, null);
    DBHelper.createAndSaveAnalysis(
        enteredSampleItem, toBeValidatedAnalysisStatus, "Hematology", null, null);

    List<Analysis> actualAnalyses =
        new AnalysisDAOImpl()
            .getAllAnalysisByAccessionNumberAndStatus(
                accessionNumber, Arrays.asList(toBeValidatedAnalysisStatus));

    Assert.assertTrue(
        "analyses should have same accessionNumber",
        matchesAccessionNumberAndStatus(
            actualAnalyses, accessionNumber, toBeValidatedAnalysisStatus));
  }