Search in sources :

Example 1 with ActivityConfigDTO

use of eu.europa.ec.fisheries.ers.service.dto.config.ActivityConfigDTO in project UVMS-ActivityModule-APP by UnionVMS.

the class ActivityConfigServiceBeanTest method testSaveUserConfig.

@Test
public void testSaveUserConfig() throws Exception {
    String updatedConfig = adminConfig;
    ActivityConfigDTO updatedConfigDto = getConfiguration(updatedConfig);
    String userJson = preferenceConfigService.saveUserConfig(updatedConfigDto, userConfig);
    assertEquals(getJson(updatedConfigDto), userJson);
}
Also used : ActivityConfigDTO(eu.europa.ec.fisheries.ers.service.dto.config.ActivityConfigDTO) Test(org.junit.Test)

Example 2 with ActivityConfigDTO

use of eu.europa.ec.fisheries.ers.service.dto.config.ActivityConfigDTO in project UVMS-ActivityModule-APP by UnionVMS.

the class ActivityConfigServiceBeanTest method testResetUserConfig.

@Test
public void testResetUserConfig() throws Exception {
    String resetConfig = "{\n" + "                    \"fishingActivityConfig\": {\n" + "                        \"summaryReport\": {\n" + "                           \n" + "                        }\n" + "                    }\n" + "                }";
    ActivityConfigDTO activityConfigDTO = getConfiguration(resetConfig);
    String userJson = preferenceConfigService.resetUserConfig(activityConfigDTO, userConfig);
    ActivityConfigDTO updated = getConfiguration(userJson);
    assertNull(updated.getFishingActivityConfig().getSummaryReport());
}
Also used : ActivityConfigDTO(eu.europa.ec.fisheries.ers.service.dto.config.ActivityConfigDTO) Test(org.junit.Test)

Example 3 with ActivityConfigDTO

use of eu.europa.ec.fisheries.ers.service.dto.config.ActivityConfigDTO in project UVMS-ActivityModule-APP by UnionVMS.

the class ActivityConfigServiceBean method saveUserConfig.

@Override
@SneakyThrows
public /**
 * {@inheritDoc}
 */
String saveUserConfig(ActivityConfigDTO updatedConfig, String userConfig) throws ServiceException {
    ActivityConfigDTO usmUserConfig = getConfiguration(userConfig);
    ActivityConfigDTO mergedConfig = PreferenceConfigMapper.INSTANCE.mergeUserPreference(usmUserConfig, updatedConfig);
    return getJson(mergedConfig);
}
Also used : ActivityConfigDTO(eu.europa.ec.fisheries.ers.service.dto.config.ActivityConfigDTO) SneakyThrows(lombok.SneakyThrows)

Example 4 with ActivityConfigDTO

use of eu.europa.ec.fisheries.ers.service.dto.config.ActivityConfigDTO in project UVMS-ActivityModule-APP by UnionVMS.

the class MapperUtil method getSourceActivityConfigDTO.

public static ActivityConfigDTO getSourceActivityConfigDTO() {
    ActivityConfigDTO activityConfigDTO = new ActivityConfigDTO();
    FishingActivityConfigDTO fishingActivityConfig = new FishingActivityConfigDTO();
    SummaryReportDTO summaryReport = new SummaryReportDTO();
    summaryReport.setValues(Arrays.asList("Report1", "Report2", "Report3"));
    summaryReport.setOrder(Arrays.asList("Report1", "Report2", "Report3"));
    fishingActivityConfig.setSummaryReport(summaryReport);
    activityConfigDTO.setFishingActivityConfig(fishingActivityConfig);
    return activityConfigDTO;
}
Also used : FishingActivityConfigDTO(eu.europa.ec.fisheries.ers.service.dto.config.FishingActivityConfigDTO) ActivityConfigDTO(eu.europa.ec.fisheries.ers.service.dto.config.ActivityConfigDTO) FishingActivityConfigDTO(eu.europa.ec.fisheries.ers.service.dto.config.FishingActivityConfigDTO) SummaryReportDTO(eu.europa.ec.fisheries.ers.service.dto.config.SummaryReportDTO)

Example 5 with ActivityConfigDTO

use of eu.europa.ec.fisheries.ers.service.dto.config.ActivityConfigDTO in project UVMS-ActivityModule-APP by UnionVMS.

the class ActivityConfigServiceBean method getConfiguration.

private ActivityConfigDTO getConfiguration(String configString) throws IOException {
    if (configString == null || configString.isEmpty()) {
        return new ActivityConfigDTO();
    }
    ObjectMapper mapper = new ObjectMapper();
    mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
    return mapper.readValue(configString, ActivityConfigDTO.class);
}
Also used : ActivityConfigDTO(eu.europa.ec.fisheries.ers.service.dto.config.ActivityConfigDTO) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

ActivityConfigDTO (eu.europa.ec.fisheries.ers.service.dto.config.ActivityConfigDTO)13 Test (org.junit.Test)7 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 FishingActivityConfigDTO (eu.europa.ec.fisheries.ers.service.dto.config.FishingActivityConfigDTO)2 SummaryReportDTO (eu.europa.ec.fisheries.ers.service.dto.config.SummaryReportDTO)2 MapperUtil.getSourceActivityConfigDTO (eu.europa.ec.fisheries.ers.service.util.MapperUtil.getSourceActivityConfigDTO)2 MapperUtil.getTargetActivityConfigDTO (eu.europa.ec.fisheries.ers.service.util.MapperUtil.getTargetActivityConfigDTO)2 SneakyThrows (lombok.SneakyThrows)2