use of eu.europa.ec.fisheries.schema.exchange.service.v1.SettingType in project UVMS-ExchangeModule-APP by UnionVMS.
the class MapperTest method testUpsert.
@Test
public void testUpsert() {
String newValue = "NEW_VALUE";
Service entity = MockData.getEntity(1);
entity.setServiceCapabilityList(MockData.getEntityCapabilities(entity));
entity.setServiceSettingList(MockData.getEntitySettings(entity));
SettingListType updateSettings = new SettingListType();
SettingType updateSetting = new SettingType();
updateSetting.setKey(MockData.SETTING_KEY);
updateSetting.setValue(newValue);
updateSettings.getSetting().add(updateSetting);
List<ServiceSetting> list = mapper.mapSettingsList(entity, updateSettings, "TEST");
assertFalse(list.isEmpty());
for (ServiceSetting setting : list) {
assertSame(setting.getValue(), newValue);
}
SettingListType newSettings = new SettingListType();
SettingType newSetting = new SettingType();
newSetting.setKey("NEW.KEY");
newSetting.setValue("NEW.VALUE");
newSettings.getSetting().add(newSetting);
list = mapper.mapSettingsList(entity, newSettings, "TEST");
assertTrue(list.size() == 1);
}
use of eu.europa.ec.fisheries.schema.exchange.service.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;
}
use of eu.europa.ec.fisheries.schema.exchange.service.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;
}
use of eu.europa.ec.fisheries.schema.exchange.service.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);
}
use of eu.europa.ec.fisheries.schema.exchange.service.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);
}
Aggregations