Search in sources :

Example 6 with CountryDto

use of de.symeda.sormas.api.infrastructure.country.CountryDto in project SORMAS-Project by hzi-braunschweig.

the class CountryFacadeEjb method toDto.

@Override
public CountryDto toDto(Country entity) {
    if (entity == null) {
        return null;
    }
    CountryDto dto = new CountryDto();
    DtoHelper.fillDto(dto, entity);
    dto.setDefaultName(entity.getDefaultName());
    dto.setArchived(entity.isArchived());
    dto.setExternalId(entity.getExternalId());
    dto.setIsoCode(entity.getIsoCode());
    dto.setUnoCode(entity.getUnoCode());
    dto.setUuid(entity.getUuid());
    dto.setSubcontinent(SubcontinentFacadeEjb.toReferenceDto(entity.getSubcontinent()));
    dto.setCentrallyManaged(entity.isCentrallyManaged());
    return dto;
}
Also used : CountryDto(de.symeda.sormas.api.infrastructure.country.CountryDto)

Example 7 with CountryDto

use of de.symeda.sormas.api.infrastructure.country.CountryDto in project SORMAS-Project by hzi-braunschweig.

the class CountryFacadeEjbTest method testDearchive.

@Test
public void testDearchive() {
    Country country = creator.createCountry("Romania", "ROU", "642");
    country.setArchived(true);
    getCountryFacade().dearchive(country.getUuid());
    CountryDto actual = getCountryFacade().getByUuid(country.getUuid());
    assertFalse(actual.isArchived());
}
Also used : CountryDto(de.symeda.sormas.api.infrastructure.country.CountryDto) Country(de.symeda.sormas.backend.infrastructure.country.Country) Test(org.junit.Test) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest)

Example 8 with CountryDto

use of de.symeda.sormas.api.infrastructure.country.CountryDto in project SORMAS-Project by hzi-braunschweig.

the class CountryFacadeEjbTest method testGetAllAfter.

@Test
public void testGetAllAfter() throws InterruptedException {
    Country country1 = creator.createCountry("Romania", "ROU", "642");
    getCountryService().doFlush();
    Date date = new Date();
    assertEquals(0, getCommunityFacade().getAllAfter(date).size());
    // delay ignoring known rounding issues in change date filter
    Thread.sleep(1);
    Country country2 = creator.createCountry("Germany", "DEU", "276");
    getCountryService().doFlush();
    List<CountryDto> results = getCountryFacade().getAllAfter(date);
    // List should have one entry
    assertEquals(1, results.size());
    assertTrue(entityIsEqualToDto(country2, results.get(0)));
}
Also used : CountryDto(de.symeda.sormas.api.infrastructure.country.CountryDto) Country(de.symeda.sormas.backend.infrastructure.country.Country) Date(java.util.Date) Test(org.junit.Test) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest)

Example 9 with CountryDto

use of de.symeda.sormas.api.infrastructure.country.CountryDto in project SORMAS-Project by hzi-braunschweig.

the class CountryFacadeEjbTest method testSaveCountrySuccessful.

@Test
public void testSaveCountrySuccessful() throws Exception {
    CountryDto expected = new CountryDto();
    expected.setDefaultName("Romania");
    expected.setIsoCode("ROU");
    expected.setUnoCode("642");
    String uuid = getCountryFacade().save(expected).getUuid();
    expected.setUuid(uuid);
    Country actual = getCountryService().getByIsoCode("ROU", false).orElseThrow(() -> new Exception("Country not found"));
    assertTrue(entityIsEqualToDto(actual, expected));
}
Also used : CountryDto(de.symeda.sormas.api.infrastructure.country.CountryDto) Country(de.symeda.sormas.backend.infrastructure.country.Country) ValidationRuntimeException(de.symeda.sormas.api.utils.ValidationRuntimeException) EmptyValueException(de.symeda.sormas.api.utils.EmptyValueException) Test(org.junit.Test) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest)

Example 10 with CountryDto

use of de.symeda.sormas.api.infrastructure.country.CountryDto in project SORMAS-Project by hzi-braunschweig.

the class CountryFacadeEjbTest method testGetCountryByUuid.

@Test
public void testGetCountryByUuid() {
    Country expected = creator.createCountry("Romania", "ROU", "642");
    getCountryService().doFlush();
    CountryDto actual = getCountryFacade().getByUuid(expected.getUuid());
    assertTrue(entityIsEqualToDto(expected, actual));
}
Also used : CountryDto(de.symeda.sormas.api.infrastructure.country.CountryDto) Country(de.symeda.sormas.backend.infrastructure.country.Country) Test(org.junit.Test) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest)

Aggregations

CountryDto (de.symeda.sormas.api.infrastructure.country.CountryDto)12 AbstractBeanTest (de.symeda.sormas.backend.AbstractBeanTest)8 Test (org.junit.Test)8 Country (de.symeda.sormas.backend.infrastructure.country.Country)5 EmptyValueException (de.symeda.sormas.api.utils.EmptyValueException)3 ValidationRuntimeException (de.symeda.sormas.api.utils.ValidationRuntimeException)3 ImportErrorException (de.symeda.sormas.api.importexport.ImportErrorException)2 InvalidColumnException (de.symeda.sormas.api.importexport.InvalidColumnException)2 CsvValidationException (com.opencsv.exceptions.CsvValidationException)1 IntrospectionException (java.beans.IntrospectionException)1 PropertyDescriptor (java.beans.PropertyDescriptor)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Date (java.util.Date)1