Search in sources :

Example 11 with MetaDataDO

use of org.apache.shenyu.admin.model.entity.MetaDataDO in project incubator-shenyu by apache.

the class MetaDataServiceTest method testFindById.

/**
 * Test case for findById.
 */
@Test
public void testFindById() {
    when(metaDataMapper.selectById(anyString())).thenReturn(null);
    MetaDataVO dataVo = metaDataService.findById(anyString());
    Assertions.assertEquals(new MetaDataVO(), dataVo);
    final String appName = "appName";
    MetaDataDO metaDataDO = MetaDataDO.builder().build();
    metaDataDO.setAppName(appName);
    when(metaDataMapper.selectById(anyString())).thenReturn(metaDataDO);
    dataVo = metaDataService.findById(anyString());
    assertEquals(appName, dataVo.getAppName());
}
Also used : MetaDataDO(org.apache.shenyu.admin.model.entity.MetaDataDO) MetaDataVO(org.apache.shenyu.admin.model.vo.MetaDataVO) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.jupiter.api.Test)

Example 12 with MetaDataDO

use of org.apache.shenyu.admin.model.entity.MetaDataDO in project incubator-shenyu by apache.

the class ShenyuClientRegisterDubboServiceImplTest method testRegisterMetadata.

@Test
public void testRegisterMetadata() {
    MetaDataDO metaDataDO = MetaDataDO.builder().build();
    when(metaDataService.findByPath(any())).thenReturn(metaDataDO);
    MetaDataRegisterDTO metaDataDTO = MetaDataRegisterDTO.builder().registerMetaData(true).build();
    shenyuClientRegisterDubboService.registerMetadata(metaDataDTO);
    verify(metaDataService).saveOrUpdateMetaData(metaDataDO, metaDataDTO);
}
Also used : MetaDataRegisterDTO(org.apache.shenyu.register.common.dto.MetaDataRegisterDTO) MetaDataDO(org.apache.shenyu.admin.model.entity.MetaDataDO) Test(org.junit.jupiter.api.Test)

Example 13 with MetaDataDO

use of org.apache.shenyu.admin.model.entity.MetaDataDO in project incubator-shenyu by apache.

the class ShenyuClientRegisterGrpcServiceImplTest method testRegisterMetadata.

@Test
public void testRegisterMetadata() {
    MetaDataDO metaDataDO = MetaDataDO.builder().build();
    when(metaDataService.findByPath(any())).thenReturn(metaDataDO);
    MetaDataRegisterDTO metaDataDTO = MetaDataRegisterDTO.builder().path("/test").build();
    shenyuClientRegisterGrpcService.registerMetadata(metaDataDTO);
    verify(metaDataService).findByPath("/test");
    verify(metaDataService).saveOrUpdateMetaData(metaDataDO, metaDataDTO);
}
Also used : MetaDataRegisterDTO(org.apache.shenyu.register.common.dto.MetaDataRegisterDTO) MetaDataDO(org.apache.shenyu.admin.model.entity.MetaDataDO) Test(org.junit.jupiter.api.Test)

Example 14 with MetaDataDO

use of org.apache.shenyu.admin.model.entity.MetaDataDO in project incubator-shenyu by apache.

the class MetaDataMapperTest method delete.

@Test
public void delete() {
    MetaDataDO metaDataDO = getMetaDataDO();
    int count = metaDataMapper.insert(metaDataDO);
    assertThat(count, comparesEqualTo(1));
    int result = metaDataMapper.delete(metaDataDO.getId());
    assertThat(result, comparesEqualTo(1));
}
Also used : MetaDataDO(org.apache.shenyu.admin.model.entity.MetaDataDO) Test(org.junit.jupiter.api.Test) AbstractSpringIntegrationTest(org.apache.shenyu.admin.AbstractSpringIntegrationTest)

Example 15 with MetaDataDO

use of org.apache.shenyu.admin.model.entity.MetaDataDO in project incubator-shenyu by apache.

the class MetaDataMapperTest method selectByIdSet.

@Test
public void selectByIdSet() {
    MetaDataDO metaDataDO = getMetaDataDO();
    int count = metaDataMapper.insert(metaDataDO);
    assertThat(count, comparesEqualTo(1));
    MetaDataDO metaDataDO2 = getMetaDataDO();
    int count2 = metaDataMapper.insert(metaDataDO2);
    assertThat(count2, comparesEqualTo(1));
    Set<String> idSet = Stream.of(metaDataDO.getId(), metaDataDO2.getId()).collect(Collectors.toSet());
    List<MetaDataDO> resultList = metaDataMapper.selectByIdSet(idSet);
    assertThat(resultList, hasItems(metaDataDO2, metaDataDO));
    assertThat(resultList.size(), comparesEqualTo(idSet.size()));
}
Also used : MetaDataDO(org.apache.shenyu.admin.model.entity.MetaDataDO) Test(org.junit.jupiter.api.Test) AbstractSpringIntegrationTest(org.apache.shenyu.admin.AbstractSpringIntegrationTest)

Aggregations

MetaDataDO (org.apache.shenyu.admin.model.entity.MetaDataDO)36 Test (org.junit.jupiter.api.Test)23 AbstractSpringIntegrationTest (org.apache.shenyu.admin.AbstractSpringIntegrationTest)14 MetaDataService (org.apache.shenyu.admin.service.MetaDataService)7 MetaDataRegisterDTO (org.apache.shenyu.register.common.dto.MetaDataRegisterDTO)7 DataChangedEvent (org.apache.shenyu.admin.listener.DataChangedEvent)4 PageParameter (org.apache.shenyu.admin.model.page.PageParameter)3 Timestamp (java.sql.Timestamp)2 MetaDataQuery (org.apache.shenyu.admin.model.query.MetaDataQuery)2 MetaDataVO (org.apache.shenyu.admin.model.vo.MetaDataVO)2 MetaDataTransfer (org.apache.shenyu.admin.transfer.MetaDataTransfer)2 MetaData (org.apache.shenyu.common.dto.MetaData)2 DataEventTypeEnum (org.apache.shenyu.common.enums.DataEventTypeEnum)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 ArrayList (java.util.ArrayList)1 Transactional (org.springframework.transaction.annotation.Transactional)1