Search in sources :

Example 16 with Service

use of eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.Service 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);
}
Also used : Service(eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.Service) SettingType(eu.europa.ec.fisheries.schema.exchange.service.v1.SettingType) SettingListType(eu.europa.ec.fisheries.schema.exchange.service.v1.SettingListType) ServiceSetting(eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.ServiceSetting) Test(org.junit.Test)

Aggregations

Service (eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.Service)16 Test (org.junit.Test)9 ServiceSetting (eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.ServiceSetting)6 ServiceType (eu.europa.ec.fisheries.schema.exchange.service.v1.ServiceType)5 SettingListType (eu.europa.ec.fisheries.schema.exchange.service.v1.SettingListType)4 ServiceCapability (eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.ServiceCapability)4 ArrayList (java.util.ArrayList)4 CapabilityListType (eu.europa.ec.fisheries.schema.exchange.service.v1.CapabilityListType)3 ExchangeDaoException (eu.europa.ec.fisheries.uvms.exchange.exception.ExchangeDaoException)3 ServiceResponseType (eu.europa.ec.fisheries.schema.exchange.service.v1.ServiceResponseType)1 SettingType (eu.europa.ec.fisheries.schema.exchange.service.v1.SettingType)1 NoEntityFoundException (eu.europa.ec.fisheries.uvms.exchange.exception.NoEntityFoundException)1 ExchangeModelException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException)1 Date (java.util.Date)1 EntityExistsException (javax.persistence.EntityExistsException)1 NoResultException (javax.persistence.NoResultException)1 DateTime (org.joda.time.DateTime)1 Ignore (org.junit.Ignore)1