Search in sources :

Example 1 with Service

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

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

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

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

the class DaoBeanTest method testUpdateService.

@Test
public void testUpdateService() throws ExchangeDaoException {
    Long id = 11L;
    Service myEntity = new Service();
    myEntity.setId(id);
    Service result = new Service();
    result.setId(id);
    when(em.merge(myEntity)).thenReturn(result);
    Service resultEntity = dao.updateService(myEntity);
    verify(em).merge(myEntity);
    assertSame(id, resultEntity.getId());
}
Also used : Service(eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.Service) Test(org.junit.Test)

Example 5 with Service

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

the class DaoBeanTest method testGetServiceById.

@Test
public void testGetServiceById() throws ExchangeDaoException {
    Long id = 1L;
    Service entity = new Service();
    entity.setId(id);
    when(em.find(Service.class, id)).thenReturn(entity);
    Service result = dao.getEntityById(id.toString());
    verify(em).find(Service.class, id);
    assertSame(id, result.getId());
}
Also used : Service(eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.Service) 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