Search in sources :

Example 11 with SettingType

use of eu.europa.ec.fisheries.schema.config.types.v1.SettingType in project UVMS-ExchangeModule-APP by UnionVMS.

the class ServiceMapper method toSettingModel.

private static SettingType toSettingModel(ServiceSetting setting) {
    SettingType model = new SettingType();
    model.setKey(setting.getSetting());
    model.setValue(setting.getValue());
    return model;
}
Also used : SettingType(eu.europa.ec.fisheries.schema.exchange.service.v1.SettingType)

Example 12 with SettingType

use of eu.europa.ec.fisheries.schema.config.types.v1.SettingType in project UVMS-ExchangeModule-APP by UnionVMS.

the class ServiceMapper method mapSettingsList.

public static List<ServiceSetting> mapSettingsList(Service parent, SettingListType settingList, String username) {
    List<ServiceSetting> newSettings = new ArrayList<>();
    List<ServiceSetting> currentSettings = parent.getServiceSettingList();
    Map<String, ServiceSetting> map = new HashMap<>();
    if (currentSettings != null) {
        for (ServiceSetting i : currentSettings) {
            map.put(i.getSetting(), i);
        }
    }
    for (SettingType setting : settingList.getSetting()) {
        ServiceSetting currentSetting = map.get(setting.getKey());
        if (currentSetting == null) {
            ServiceSetting newSetting = toSettingEntity(parent, setting, username);
            newSettings.add(newSetting);
        } else {
            if (!currentSetting.getValue().equalsIgnoreCase(setting.getValue())) {
                currentSetting.setValue(setting.getValue());
                currentSetting.setUpdatedTime(DateUtils.nowUTC().toDate());
                currentSetting.setUser(username);
            }
            newSettings.add(currentSetting);
        }
    }
    return newSettings;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) SettingType(eu.europa.ec.fisheries.schema.exchange.service.v1.SettingType) ServiceSetting(eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.ServiceSetting)

Example 13 with SettingType

use of eu.europa.ec.fisheries.schema.config.types.v1.SettingType in project UVMS-Docker by UnionVMS.

the class SettingsRestIT method getByIdTest.

/**
 * Gets the by id test.
 *
 * @return the by id test
 * @throws Exception the exception
 */
@Test
public void getByIdTest() throws Exception {
    SettingType settingType = createTestSettingType();
    assertNotNull(settingType);
    final HttpResponse response = Request.Get(getBaseUrl() + "config/rest/settings/" + settingType.getId()).setHeader("Content-Type", "application/json").setHeader("Authorization", getValidJwtToken()).execute().returnResponse();
    Map<String, Object> dataMap = checkSuccessResponseReturnMap(response);
}
Also used : HttpResponse(org.apache.http.HttpResponse) SettingType(eu.europa.ec.fisheries.schema.config.types.v1.SettingType) Test(org.junit.Test) AbstractRestServiceTest(eu.europa.ec.fisheries.uvms.docker.validation.common.AbstractRestServiceTest)

Example 14 with SettingType

use of eu.europa.ec.fisheries.schema.config.types.v1.SettingType in project UVMS-Docker by UnionVMS.

the class SettingsRestIT method updateTest.

/**
 * Update test.
 *
 * @throws Exception the exception
 */
@Test
public void updateTest() throws Exception {
    SettingType settingType = createTestSettingType();
    assertNotNull(settingType);
    settingType.setDescription("Updated Desc" + UUID.randomUUID().toString());
    final HttpResponse response = Request.Put(getBaseUrl() + "config/rest/settings/" + settingType.getId()).setHeader("Content-Type", "application/json").setHeader("Authorization", getValidJwtToken()).bodyByteArray(writeValueAsString(settingType).getBytes()).execute().returnResponse();
    Map<String, Object> dataMap = checkSuccessResponseReturnMap(response);
}
Also used : HttpResponse(org.apache.http.HttpResponse) SettingType(eu.europa.ec.fisheries.schema.config.types.v1.SettingType) Test(org.junit.Test) AbstractRestServiceTest(eu.europa.ec.fisheries.uvms.docker.validation.common.AbstractRestServiceTest)

Aggregations

SettingType (eu.europa.ec.fisheries.schema.exchange.service.v1.SettingType)9 SettingType (eu.europa.ec.fisheries.schema.config.types.v1.SettingType)5 Test (org.junit.Test)5 AbstractRestServiceTest (eu.europa.ec.fisheries.uvms.docker.validation.common.AbstractRestServiceTest)4 HttpResponse (org.apache.http.HttpResponse)4 SettingListType (eu.europa.ec.fisheries.schema.exchange.service.v1.SettingListType)3 ConfigServiceException (eu.europa.ec.fisheries.uvms.config.exception.ConfigServiceException)3 ServiceSetting (eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.ServiceSetting)2 ExchangeServiceException (eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeServiceException)2 HashMap (java.util.HashMap)2 SettingsCreateQuery (eu.europa.ec.fisheries.schema.config.types.v1.SettingsCreateQuery)1 ServiceResponseType (eu.europa.ec.fisheries.schema.exchange.service.v1.ServiceResponseType)1 Service (eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.Service)1 ExchangeMessageException (eu.europa.ec.fisheries.uvms.exchange.message.exception.ExchangeMessageException)1 ExchangeModelMapperException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMapperException)1 ExchangeModelMarshallException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException)1 ArrayList (java.util.ArrayList)1