Search in sources :

Example 1 with ServiceSetting

use of eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.ServiceSetting in project UVMS-ExchangeModule-APP by UnionVMS.

the class MapperTest method testEntityToModel.

// private void mockDaoToEntity() throws ExchangeDaoException {
// when(enumDao.getMyEntityEnum(any(MyEntityEnumSource.class))).thenReturn(MyEntityEnum.VALUE_1);
// }
@Test
public void testEntityToModel() throws ExchangeDaoException, ExchangeDaoMappingException {
    Integer id = 1;
    Service entity = MockData.getEntity(id);
    List<ServiceCapability> capabilityList = new ArrayList<>();
    entity.setServiceCapabilityList(capabilityList);
    List<ServiceSetting> settingList = new ArrayList<>();
    entity.setServiceSettingList(settingList);
    // mockDaoToEntity();
    ServiceType result = mapper.toServiceModel(entity);
    assertSame(entity.getName(), result.getName());
    assertSame(entity.getServiceClassName(), result.getServiceClassName());
}
Also used : ServiceType(eu.europa.ec.fisheries.schema.exchange.service.v1.ServiceType) ArrayList(java.util.ArrayList) Service(eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.Service) ServiceCapability(eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.ServiceCapability) ServiceSetting(eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.ServiceSetting) Test(org.junit.Test)

Example 2 with ServiceSetting

use of eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.ServiceSetting in project UVMS-ExchangeModule-APP by UnionVMS.

the class MapperTest method testEntityAndModelToModel.

@Test
public void testEntityAndModelToModel() throws ExchangeDaoException, ExchangeDaoMappingException {
    Service entity = MockData.getEntity(1);
    List<ServiceCapability> capabilityList = new ArrayList<>();
    entity.setServiceCapabilityList(capabilityList);
    List<ServiceSetting> settingList = new ArrayList<>();
    entity.setServiceSettingList(settingList);
    // mockDaoToEntity();
    ServiceType result = mapper.toServiceModel(entity);
    assertSame(entity.getName(), result.getName());
    assertSame(entity.getServiceClassName(), result.getServiceClassName());
}
Also used : ServiceType(eu.europa.ec.fisheries.schema.exchange.service.v1.ServiceType) ArrayList(java.util.ArrayList) Service(eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.Service) ServiceCapability(eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.ServiceCapability) ServiceSetting(eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.ServiceSetting) Test(org.junit.Test)

Example 3 with ServiceSetting

use of eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.ServiceSetting 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 ServiceSetting

use of eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.ServiceSetting in project UVMS-ExchangeModule-APP by UnionVMS.

the class ServiceMapper method toSettingEntity.

private static ServiceSetting toSettingEntity(Service parent, SettingType setting, String username) {
    ServiceSetting entity = new ServiceSetting();
    entity.setService(parent);
    entity.setSetting(setting.getKey());
    entity.setUpdatedTime(DateUtils.nowUTC().toDate());
    entity.setUser(username);
    entity.setValue(setting.getValue());
    return entity;
}
Also used : ServiceSetting(eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.ServiceSetting)

Example 5 with ServiceSetting

use of eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.ServiceSetting in project UVMS-ExchangeModule-APP by UnionVMS.

the class ServiceRegistryModelBean method getPluginSettings.

@Override
public List<SettingType> getPluginSettings(String serviceClassName) throws ExchangeModelException {
    LOG.info("Get plugin settings:{}", serviceClassName);
    List<SettingType> settings = new ArrayList<>();
    try {
        List<ServiceSetting> entityList = dao.getServiceSettings(serviceClassName);
        for (ServiceSetting entity : entityList) {
            settings.add(ServiceMapper.toModel(entity));
        }
    } catch (ExchangeDaoException e) {
        LOG.error("[ Error when getting list. {}] {}", serviceClassName, e.getMessage());
        throw new ExchangeModelException("[ Error when getting list. ]");
    }
    return settings;
}
Also used : ExchangeDaoException(eu.europa.ec.fisheries.uvms.exchange.exception.ExchangeDaoException) ArrayList(java.util.ArrayList) ExchangeModelException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException) ServiceSetting(eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.ServiceSetting)

Aggregations

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