Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
fixes #1880 pagination not work
- Loading branch information
1 parent
f99d54a
commit db54e50
Showing
4 changed files
with
62 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
...src/test/java/com/ctrip/framework/apollo/biz/repository/InstanceConfigRepositoryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package com.ctrip.framework.apollo.biz.repository; | ||
|
||
import com.ctrip.framework.apollo.biz.AbstractIntegrationTest; | ||
import com.ctrip.framework.apollo.biz.entity.Instance; | ||
import com.ctrip.framework.apollo.biz.entity.InstanceConfig; | ||
import java.util.Date; | ||
import org.junit.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.PageRequest; | ||
import org.springframework.test.annotation.Rollback; | ||
|
||
import static org.hamcrest.Matchers.hasSize; | ||
import static org.junit.Assert.assertThat; | ||
|
||
/** | ||
* Created by kezhenxu94 at 2019/1/18 15:33. | ||
* | ||
* @author kezhenxu94 (kezhenxu94 at 163 dot com) | ||
*/ | ||
public class InstanceConfigRepositoryTest extends AbstractIntegrationTest { | ||
@Autowired | ||
private InstanceConfigRepository instanceConfigRepository; | ||
@Autowired | ||
private InstanceRepository instanceRepository; | ||
|
||
@Rollback | ||
@Test | ||
public void shouldPaginated() { | ||
for (int i = 0; i < 25; i++) { | ||
Instance instance = new Instance(); | ||
instance.setAppId("appId"); | ||
instanceRepository.save(instance); | ||
|
||
final InstanceConfig instanceConfig = new InstanceConfig(); | ||
instanceConfig.setConfigAppId("appId"); | ||
instanceConfig.setInstanceId(instance.getId()); | ||
instanceConfig.setConfigClusterName("cluster"); | ||
instanceConfig.setConfigNamespaceName("namespace"); | ||
instanceConfigRepository.save(instanceConfig); | ||
} | ||
Page<Object> ids = instanceConfigRepository.findInstanceIdsByNamespaceAndInstanceAppId( | ||
"appId", "appId", "cluster", "namespace", new Date(0), PageRequest.of(0, 10) | ||
); | ||
assertThat(ids.getContent(), hasSize(10)); | ||
|
||
ids = instanceConfigRepository.findInstanceIdsByNamespaceAndInstanceAppId( | ||
"appId", "appId", "cluster", "namespace", new Date(0), PageRequest.of(1, 10) | ||
); | ||
assertThat(ids.getContent(), hasSize(10)); | ||
|
||
ids = instanceConfigRepository.findInstanceIdsByNamespaceAndInstanceAppId( | ||
"appId", "appId", "cluster", "namespace", new Date(0), PageRequest.of(2, 10) | ||
); | ||
assertThat(ids.getContent(), hasSize(5)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters