Search in sources :

Example 1 with MetaDataVO

use of org.apache.shenyu.admin.model.vo.MetaDataVO in project incubator-shenyu by apache.

the class MetaDataServiceTest method testListByPage.

/**
 * Test case for listByPage.
 */
@Test
public void testListByPage() {
    when(metaDataQuery.getPageParameter()).thenReturn(new PageParameter(1, 10, 5));
    ArrayList<MetaDataDO> metaDataDOList = getMetaDataDOList();
    when(metaDataMapper.selectByQuery(any())).thenReturn(metaDataDOList);
    CommonPager<MetaDataVO> pager = metaDataService.listByPage(metaDataQuery);
    Assertions.assertEquals(metaDataDOList.size(), pager.getDataList().size(), "The dataList should be contain " + metaDataDOList.size() + " element.");
}
Also used : MetaDataDO(org.apache.shenyu.admin.model.entity.MetaDataDO) PageParameter(org.apache.shenyu.admin.model.page.PageParameter) MetaDataVO(org.apache.shenyu.admin.model.vo.MetaDataVO) Test(org.junit.jupiter.api.Test)

Example 2 with MetaDataVO

use of org.apache.shenyu.admin.model.vo.MetaDataVO 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 3 with MetaDataVO

use of org.apache.shenyu.admin.model.vo.MetaDataVO in project incubator-shenyu by apache.

the class MetaDataControllerTest method testQueryList.

@Test
public void testQueryList() throws Exception {
    final PageParameter pageParameter = new PageParameter();
    List<MetaDataVO> metaDataVOS = new ArrayList<>();
    metaDataVOS.add(metaDataVO);
    final CommonPager<MetaDataVO> commonPager = new CommonPager<>();
    commonPager.setPage(pageParameter);
    commonPager.setDataList(metaDataVOS);
    final MetaDataQuery metaDataQuery = new MetaDataQuery("appName", pageParameter);
    given(this.metaDataService.listByPage(metaDataQuery)).willReturn(commonPager);
    this.mockMvc.perform(MockMvcRequestBuilders.get("/meta-data/queryList").param("appName", "appName").param("currentPage", pageParameter.getCurrentPage() + "").param("pageSize", pageParameter.getPageSize() + "")).andExpect(status().isOk()).andExpect(jsonPath("$.message", is(ShenyuResultMessage.QUERY_SUCCESS))).andExpect(jsonPath("$.data.dataList[0].appName", is(metaDataVO.getAppName()))).andReturn();
}
Also used : MetaDataQuery(org.apache.shenyu.admin.model.query.MetaDataQuery) ArrayList(java.util.ArrayList) PageParameter(org.apache.shenyu.admin.model.page.PageParameter) MetaDataVO(org.apache.shenyu.admin.model.vo.MetaDataVO) CommonPager(org.apache.shenyu.admin.model.page.CommonPager) Test(org.junit.jupiter.api.Test)

Aggregations

MetaDataVO (org.apache.shenyu.admin.model.vo.MetaDataVO)3 Test (org.junit.jupiter.api.Test)3 MetaDataDO (org.apache.shenyu.admin.model.entity.MetaDataDO)2 PageParameter (org.apache.shenyu.admin.model.page.PageParameter)2 ArrayList (java.util.ArrayList)1 CommonPager (org.apache.shenyu.admin.model.page.CommonPager)1 MetaDataQuery (org.apache.shenyu.admin.model.query.MetaDataQuery)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1