Search in sources :

Example 1 with SettingListType

use of eu.europa.ec.fisheries.schema.exchange.service.v1.SettingListType in project UVMS-ExchangeModule-APP by UnionVMS.

the class MapperTest method testModelToEntity.

@Test
public void testModelToEntity() throws ExchangeDaoException, ExchangeDaoMappingException {
    Integer id = 1;
    ServiceType model = MockData.getModel(id);
    CapabilityListType capabilityListType = MockData.getCapabilityList();
    SettingListType settingListType = MockData.getSettingList();
    // mockDaoToEntity();
    Service result = mapper.toServiceEntity(model, capabilityListType, settingListType, "TEST");
    assertSame(model.getName(), result.getName());
    assertSame(model.getServiceClassName(), result.getServiceClassName());
}
Also used : CapabilityListType(eu.europa.ec.fisheries.schema.exchange.service.v1.CapabilityListType) ServiceType(eu.europa.ec.fisheries.schema.exchange.service.v1.ServiceType) Service(eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.Service) SettingListType(eu.europa.ec.fisheries.schema.exchange.service.v1.SettingListType) Test(org.junit.Test)

Example 2 with SettingListType

use of eu.europa.ec.fisheries.schema.exchange.service.v1.SettingListType in project UVMS-ExchangeModule-APP by UnionVMS.

the class ServiceMapper method toServiceModel.

public static ServiceResponseType toServiceModel(Service entity) {
    ServiceResponseType model = new ServiceResponseType();
    model.setDescription(entity.getDescription());
    model.setName(entity.getName());
    model.setServiceClassName(entity.getServiceClassName());
    CapabilityListType capabilityList = toCapabilityListModel(entity.getServiceCapabilityList());
    model.setCapabilityList(capabilityList);
    model.setServiceResponseMessageName(entity.getServiceResponse());
    model.setPluginType(entity.getType());
    model.setSatelliteType(entity.getSatelliteType());
    model.setStatus(mapStatus(entity.getStatus()));
    model.setActive(entity.getActive());
    SettingListType settingList = toSettingListModel(entity.getServiceSettingList());
    model.setSettingList(settingList);
    return model;
}
Also used : CapabilityListType(eu.europa.ec.fisheries.schema.exchange.service.v1.CapabilityListType) ServiceResponseType(eu.europa.ec.fisheries.schema.exchange.service.v1.ServiceResponseType) SettingListType(eu.europa.ec.fisheries.schema.exchange.service.v1.SettingListType)

Example 3 with SettingListType

use of eu.europa.ec.fisheries.schema.exchange.service.v1.SettingListType in project UVMS-ExchangeModule-APP by UnionVMS.

the class DomainModelBeanTest method testCreateModel.

@Ignore
@Test
public void testCreateModel() throws ExchangeModelException, ExchangeDaoException, ExchangeDaoMappingException {
    Long id = 1L;
    ServiceType serviceType = MockData.getModel(id.intValue());
    CapabilityListType capabilityListType = MockData.getCapabilityList();
    SettingListType settingListType = MockData.getSettingList();
    Service service = new Service();
    service.setId(id);
    service.setActive(false);
    List<ServiceCapability> serviceCapabilityList = new ArrayList<>();
    service.setServiceCapabilityList(serviceCapabilityList);
    List<ServiceSetting> serviceSettingList = new ArrayList<>();
    service.setServiceSettingList(serviceSettingList);
    when(dao.getServiceByServiceClassName(any(String.class))).thenReturn(null);
    // when(dao.updateService(any(Service.class))).thenReturn(service);
    ServiceResponseType result = model.registerService(serviceType, capabilityListType, settingListType, "TEST");
// assertEquals(id.toString(), result.getId());
}
Also used : CapabilityListType(eu.europa.ec.fisheries.schema.exchange.service.v1.CapabilityListType) ServiceType(eu.europa.ec.fisheries.schema.exchange.service.v1.ServiceType) ServiceResponseType(eu.europa.ec.fisheries.schema.exchange.service.v1.ServiceResponseType) ArrayList(java.util.ArrayList) Service(eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.Service) ServiceCapability(eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.ServiceCapability) SettingListType(eu.europa.ec.fisheries.schema.exchange.service.v1.SettingListType) ServiceSetting(eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.ServiceSetting) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 4 with SettingListType

use of eu.europa.ec.fisheries.schema.exchange.service.v1.SettingListType in project UVMS-ExchangeModule-APP by UnionVMS.

the class ExchangeServiceBean method upsertSettings.

@Override
public ServiceResponseType upsertSettings(String serviceClassName, SettingListType settingListType, String username) throws ExchangeServiceException {
    LOG.info("Upsert settings in service layer: {} {} {}", serviceClassName, settingListType, username);
    try {
        ServiceResponseType updatedSettings = serviceRegistryModel.updatePluginSettings(serviceClassName, settingListType, username);
        sendAuditLogMessageForUpdateService(compressServiceClassName(serviceClassName), username);
        return updatedSettings;
    } catch (ExchangeModelException e) {
        throw new ExchangeServiceException(e.getMessage());
    }
}
Also used : ServiceResponseType(eu.europa.ec.fisheries.schema.exchange.service.v1.ServiceResponseType) ExchangeModelException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException) ExchangeServiceException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeServiceException)

Example 5 with SettingListType

use of eu.europa.ec.fisheries.schema.exchange.service.v1.SettingListType 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

SettingListType (eu.europa.ec.fisheries.schema.exchange.service.v1.SettingListType)8 ServiceResponseType (eu.europa.ec.fisheries.schema.exchange.service.v1.ServiceResponseType)6 CapabilityListType (eu.europa.ec.fisheries.schema.exchange.service.v1.CapabilityListType)4 SettingType (eu.europa.ec.fisheries.schema.exchange.service.v1.SettingType)4 Service (eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.Service)4 Test (org.junit.Test)4 ServiceType (eu.europa.ec.fisheries.schema.exchange.service.v1.ServiceType)3 ServiceSetting (eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.ServiceSetting)3 ExchangeServiceException (eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeServiceException)3 ExchangeModelException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException)2 ExchangeModelMapperException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMapperException)2 ArrayList (java.util.ArrayList)2 ConfigServiceException (eu.europa.ec.fisheries.uvms.config.exception.ConfigServiceException)1 ServiceCapability (eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.ServiceCapability)1 HashMap (java.util.HashMap)1 Ignore (org.junit.Ignore)1