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());
}
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);
}
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);
}
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));
}
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()));
}
Aggregations