Пример #1
0
  @Test
  public void testImportDataValuesXmlWithCodeA() throws Exception {
    in = new ClassPathResource("datavalueset/dataValueSetACode.xml").getInputStream();

    ImportSummary summary = dataValueSetService.saveDataValueSet(in);

    assertNotNull(summary);
    assertNotNull(summary.getImportCount());
    assertEquals(ImportStatus.SUCCESS, summary.getStatus());
    assertEquals(summary.getConflicts().toString(), 0, summary.getConflicts().size());

    Collection<DataValue> dataValues = mockDataValueBatchHandler.getInserts();

    assertNotNull(dataValues);
    assertEquals(3, dataValues.size());
    assertTrue(dataValues.contains(new DataValue(deA, peA, ouA, ocDef, ocDef)));
    assertTrue(dataValues.contains(new DataValue(deB, peA, ouA, ocDef, ocDef)));
    assertTrue(dataValues.contains(new DataValue(deC, peA, ouA, ocDef, ocDef)));

    CompleteDataSetRegistration registration =
        registrationService.getCompleteDataSetRegistration(dsA, peA, ouA, ocDef);

    assertNotNull(registration);
    assertEquals(dsA, registration.getDataSet());
    assertEquals(peA, registration.getPeriod());
    assertEquals(ouA, registration.getSource());
    assertEquals(getDate(2012, 1, 9), registration.getDate());
  }
  private void deleteCompleteDataSetRegistrationsBySource(int sourceId) {
    Collection<ImportObject> importObjects =
        importObjectStore.getImportObjects(CompleteDataSetRegistration.class);

    for (ImportObject importObject : importObjects) {
      CompleteDataSetRegistration registration =
          (CompleteDataSetRegistration) importObject.getObject();

      if (registration.getSource().getId() == sourceId) {
        importObjectStore.deleteImportObject(importObject);
      }
    }
  }