本文整理匯總了Java中org.springframework.hateoas.PagedResources.PageMetadata方法的典型用法代碼示例。如果您正苦於以下問題:Java PagedResources.PageMetadata方法的具體用法?Java PagedResources.PageMetadata怎麽用?Java PagedResources.PageMetadata使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.hateoas.PagedResources
的用法示例。
在下文中一共展示了PagedResources.PageMetadata方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: importFromLocalResource
import org.springframework.hateoas.PagedResources; //導入方法依賴的package包/類
@Test
public void importFromLocalResource() {
String name1 = "foo";
String type1 = "source";
String uri1 = "file:///foo";
String name2 = "bar";
String type2 = "sink";
String uri2 = "file:///bar";
Properties apps = new Properties();
apps.setProperty(type1 + "." + name1, uri1);
apps.setProperty(type2 + "." + name2, uri2);
List<AppRegistrationResource> resources = new ArrayList<>();
resources.add(new AppRegistrationResource(name1, type1, uri1));
resources.add(new AppRegistrationResource(name2, type2, uri2));
PagedResources<AppRegistrationResource> pagedResources = new PagedResources<>(resources,
new PagedResources.PageMetadata(resources.size(), 1, resources.size(), 1));
when(appRegistryOperations.registerAll(apps, true)).thenReturn(pagedResources);
String appsFileUri = "classpath:appRegistryCommandsTests-apps.properties";
String result = appRegistryCommands.importFromResource(appsFileUri, true, true);
assertEquals("Successfully registered applications: [source.foo, sink.bar]", result);
}
示例2: testStatusWithSummary
import org.springframework.hateoas.PagedResources; //導入方法依賴的package包/類
@Test
public void testStatusWithSummary() {
Collection<AppStatusResource> data = new ArrayList<>();
data.add(appStatusResource1);
data.add(appStatusResource2);
data.add(appStatusResource3);
PagedResources.PageMetadata metadata = new PagedResources.PageMetadata(data.size(), 1, data.size(), 1);
PagedResources<AppStatusResource> result = new PagedResources<>(data, metadata);
when(runtimeOperations.status()).thenReturn(result);
Object[][] expected = new String[][] {
{"1", "deployed", "2"},
{"2", "undeployed", "0"},
{"3", "failed", "0"}
};
TableModel model = runtimeCommands.list(true, null).getModel();
for (int row = 0; row < expected.length; row++) {
for (int col = 0; col < expected[row].length; col++) {
assertThat(String.valueOf(model.getValue(row + 1, col)), Matchers.is(expected[row][col]));
}
}
}
示例3: testStatusWithoutSummary
import org.springframework.hateoas.PagedResources; //導入方法依賴的package包/類
@Test
public void testStatusWithoutSummary() {
Collection<AppStatusResource> data = new ArrayList<>();
data.add(appStatusResource1);
data.add(appStatusResource2);
PagedResources.PageMetadata metadata = new PagedResources.PageMetadata(data.size(), 1, data.size(), 1);
PagedResources<AppStatusResource> result = new PagedResources<>(data, metadata);
when(runtimeOperations.status()).thenReturn(result);
Object[][] expected = new String[][] {
{"1", "deployed", "2"},
{"10", "deployed"},
{"20", "deployed"},
{"2", "undeployed", "0"}
};
TableModel model = runtimeCommands.list(false, null).getModel();
for (int row = 0; row < expected.length; row++) {
for (int col = 0; col < expected[row].length; col++) {
assertThat(String.valueOf(model.getValue(row + 1, col)), Matchers.is(expected[row][col]));
}
}
}
示例4: testList
import org.springframework.hateoas.PagedResources; //導入方法依賴的package包/類
@Test
public void testList() {
String[][] apps = new String[][] { { "http", "source" }, { "filter", "processor" },
{ "transform", "processor" }, { "file", "source" }, { "log", "sink" },
{ "moving-average", "processor" } };
Collection<AppRegistrationResource> data = new ArrayList<>();
for (String[] app : apps) {
data.add(new AppRegistrationResource(app[0], app[1], null));
}
PagedResources.PageMetadata metadata = new PagedResources.PageMetadata(data.size(), 1, data.size(), 1);
PagedResources<AppRegistrationResource> result = new PagedResources<>(data, metadata);
when(appRegistryOperations.list()).thenReturn(result);
Object[][] expected = new String[][] { { "source", "processor", "sink", "task" },
{ "http", "filter", "log", null }, { "file", "transform", null, null },
{ null, "moving-average", null, null }, };
TableModel model = ((Table) appRegistryCommands.list(null)).getModel();
for (int row = 0; row < expected.length; row++) {
for (int col = 0; col < expected[row].length; col++) {
assertThat(model.getValue(row, col), Matchers.is(expected[row][col]));
}
}
}
示例5: importFromLocalResource
import org.springframework.hateoas.PagedResources; //導入方法依賴的package包/類
@Test
public void importFromLocalResource() {
String name1 = "foo";
ApplicationType type1 = ApplicationType.source;
String uri1 = "file:///foo";
String name2 = "bar";
ApplicationType type2 = ApplicationType.sink;
String uri2 = "file:///bar";
Properties apps = new Properties();
apps.setProperty(type1.name() + "." + name1, uri1);
apps.setProperty(type2.name() + "." + name2, uri2);
List<AppRegistrationResource> resources = new ArrayList<>();
resources.add(new AppRegistrationResource(name1, type1.name(), uri1));
resources.add(new AppRegistrationResource(name2, type2.name(), uri2));
PagedResources<AppRegistrationResource> pagedResources = new PagedResources<>(resources,
new PagedResources.PageMetadata(resources.size(), 1, resources.size(), 1));
when(appRegistryOperations.registerAll(apps, true)).thenReturn(pagedResources);
String appsFileUri = "classpath:appRegistryCommandsTests-apps.properties";
String result = appRegistryCommands.importFromResource(appsFileUri, true, true);
assertEquals("Successfully registered applications: [source.foo, sink.bar]", result);
}
示例6: testStatusWithSummary
import org.springframework.hateoas.PagedResources; //導入方法依賴的package包/類
@Test
public void testStatusWithSummary() {
Collection<AppStatusResource> data = new ArrayList<>();
data.add(appStatusResource1);
data.add(appStatusResource2);
data.add(appStatusResource3);
PagedResources.PageMetadata metadata = new PagedResources.PageMetadata(data.size(), 1, data.size(), 1);
PagedResources<AppStatusResource> result = new PagedResources<>(data, metadata);
when(runtimeOperations.status()).thenReturn(result);
Object[][] expected = new String[][] { { "1", "deployed", "2" }, { "2", "undeployed", "0" },
{ "3", "failed", "0" } };
TableModel model = runtimeCommands.list(true, null).getModel();
for (int row = 0; row < expected.length; row++) {
for (int col = 0; col < expected[row].length; col++) {
assertThat(String.valueOf(model.getValue(row + 1, col)), Matchers.is(expected[row][col]));
}
}
}
示例7: testStatusWithoutSummary
import org.springframework.hateoas.PagedResources; //導入方法依賴的package包/類
@Test
public void testStatusWithoutSummary() {
Collection<AppStatusResource> data = new ArrayList<>();
data.add(appStatusResource1);
data.add(appStatusResource2);
PagedResources.PageMetadata metadata = new PagedResources.PageMetadata(data.size(), 1, data.size(), 1);
PagedResources<AppStatusResource> result = new PagedResources<>(data, metadata);
when(runtimeOperations.status()).thenReturn(result);
Object[][] expected = new String[][] { { "1", "deployed", "2" }, { "10", "deployed" }, { "20", "deployed" },
{ "2", "undeployed", "0" } };
TableModel model = runtimeCommands.list(false, null).getModel();
for (int row = 0; row < expected.length; row++) {
for (int col = 0; col < expected[row].length; col++) {
assertThat(String.valueOf(model.getValue(row + 1, col)), Matchers.is(expected[row][col]));
}
}
}
示例8: fetchMetrics
import org.springframework.hateoas.PagedResources; //導入方法依賴的package包/類
@RequestMapping(produces = {MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<PagedResources<StreamMetrics>> fetchMetrics(
@RequestParam(value = "name", defaultValue = "") String name) {
Collection<StreamMetrics> entries = service.toStreamMetrics(name);
int totalPages = (entries.size() == 0) ? 0 : entries.size() / entries.size();
PagedResources.PageMetadata pageMetadata = new PagedResources.PageMetadata(entries.size(), 0, entries.size(),
totalPages);
PagedResources<StreamMetrics> pagedResources = new PagedResources<>(entries, pageMetadata,
ControllerLinkBuilder.linkTo(MetricsCollectorEndpoint.class).withRel(Link.REL_SELF));
return new ResponseEntity<PagedResources<StreamMetrics>>(pagedResources, HttpStatus.OK);
}
開發者ID:spring-cloud,項目名稱:spring-cloud-dataflow-metrics-collector,代碼行數:15,代碼來源:MetricsCollectorEndpoint.java
示例9: testHintOnEmptyList
import org.springframework.hateoas.PagedResources; //導入方法依賴的package包/類
@Test
public void testHintOnEmptyList() {
Collection<AppRegistrationResource> data = new ArrayList<>();
PagedResources.PageMetadata metadata = new PagedResources.PageMetadata(data.size(), 1, data.size(), 1);
PagedResources<AppRegistrationResource> result = new PagedResources<>(data, metadata);
when(appRegistryOperations.list()).thenReturn(result);
Object commandResult = appRegistryCommands.list();
assertThat((String) commandResult, CoreMatchers.containsString("app register"));
assertThat((String) commandResult, CoreMatchers.containsString("app import"));
}
示例10: testList
import org.springframework.hateoas.PagedResources; //導入方法依賴的package包/類
@Test
public void testList() {
String[][] apps = new String[][] {
{"http", "source"},
{"filter", "processor"},
{"transform", "processor"},
{"file", "source"},
{"log", "sink"},
{"moving-average", "processor"}
};
Collection<AppRegistrationResource> data = new ArrayList<>();
for (String[] app : apps) {
data.add(new AppRegistrationResource(app[0], app[1], null));
}
PagedResources.PageMetadata metadata = new PagedResources.PageMetadata(data.size(), 1, data.size(), 1);
PagedResources<AppRegistrationResource> result = new PagedResources<>(data, metadata);
when(appRegistryOperations.list()).thenReturn(result);
Object[][] expected = new String[][] {
{ "source", "processor", "sink" },
{ "http", "filter", "log" },
{ "file", "transform", null },
{ null, "moving-average", null }
};
TableModel model = ((Table) appRegistryCommands.list()).getModel();
for (int row = 0; row < expected.length; row++) {
for (int col = 0; col < expected[row].length; col++) {
assertThat(model.getValue(row, col), Matchers.is(expected[row][col]));
}
}
}
示例11: importFromResource
import org.springframework.hateoas.PagedResources; //導入方法依賴的package包/類
@Test
public void importFromResource() {
List<AppRegistrationResource> resources = new ArrayList<>();
resources.add(new AppRegistrationResource("foo", "source", null));
resources.add(new AppRegistrationResource("bar", "sink", null));
PagedResources<AppRegistrationResource> pagedResources = new PagedResources<>(resources,
new PagedResources.PageMetadata(resources.size(), 1, resources.size(), 1));
String uri = "test://example";
when(appRegistryOperations.importFromResource(uri, true)).thenReturn(pagedResources);
String result = appRegistryCommands.importFromResource(uri, false, true);
assertEquals("Successfully registered 2 applications from 'test://example'", result);
}
示例12: setUp
import org.springframework.hateoas.PagedResources; //導入方法依賴的package包/類
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
when(dataFlowOperations.runtimeOperations()).thenReturn(runtimeOperations);
DataFlowShell dataFlowShell = new DataFlowShell();
dataFlowShell.setDataFlowOperations(dataFlowOperations);
this.runtimeCommands = new RuntimeCommands(dataFlowShell);
appStatusResource1 = new AppStatusResource("1", "deployed");
Map<String, String> properties = new HashMap<>();
properties.put("key1", "value1");
properties.put("key2", "value1");
AppInstanceStatusResource instanceStatusResource1 = new AppInstanceStatusResource("10", "deployed", properties);
AppInstanceStatusResource instanceStatusResource2 = new AppInstanceStatusResource("20", "deployed", null);
List<AppInstanceStatusResource> instanceStatusResources1 = new ArrayList<>();
instanceStatusResources1.add(instanceStatusResource1);
instanceStatusResources1.add(instanceStatusResource2);
PagedResources.PageMetadata metadata1 = new PagedResources.PageMetadata(instanceStatusResources1.size(), 1, instanceStatusResources1.size(), 1);
PagedResources<AppInstanceStatusResource> resources = new PagedResources<>(instanceStatusResources1, metadata1);
appStatusResource1.setInstances(resources);
appStatusResource2 = new AppStatusResource("2", "undeployed");
AppInstanceStatusResource instanceStatusResource3 = new AppInstanceStatusResource("30", "undeployed", null);
AppInstanceStatusResource instanceStatusResource4 = new AppInstanceStatusResource("40", "undeployed", null);
List<AppInstanceStatusResource> instanceStatusResources2 = new ArrayList<>();
instanceStatusResources1.add(instanceStatusResource3);
instanceStatusResources1.add(instanceStatusResource4);
PagedResources.PageMetadata metadata3 = new PagedResources.PageMetadata(instanceStatusResources2.size(), 1, instanceStatusResources2.size(), 1);
PagedResources<AppInstanceStatusResource> resources2 = new PagedResources<>(instanceStatusResources2, metadata3);
appStatusResource2.setInstances(resources2);
appStatusResource3 = new AppStatusResource("3", "failed");
AppInstanceStatusResource instanceStatusResource5 = new AppInstanceStatusResource("50", "failed", null);
AppInstanceStatusResource instanceStatusResource6 = new AppInstanceStatusResource("60", "deployed", null);
List<AppInstanceStatusResource> instanceStatusResources3 = new ArrayList<>();
instanceStatusResources1.add(instanceStatusResource5);
instanceStatusResources1.add(instanceStatusResource6);
PagedResources.PageMetadata metadata4 = new PagedResources.PageMetadata(instanceStatusResources3.size(), 1, instanceStatusResources3.size(), 1);
PagedResources<AppInstanceStatusResource> resources3 = new PagedResources<>(instanceStatusResources3, metadata4);
appStatusResource3.setInstances(resources3);
}
示例13: testHintOnEmptyList
import org.springframework.hateoas.PagedResources; //導入方法依賴的package包/類
@Test
public void testHintOnEmptyList() {
Collection<AppRegistrationResource> data = new ArrayList<>();
PagedResources.PageMetadata metadata = new PagedResources.PageMetadata(data.size(), 1, data.size(), 1);
PagedResources<AppRegistrationResource> result = new PagedResources<>(data, metadata);
when(appRegistryOperations.list()).thenReturn(result);
Object commandResult = appRegistryCommands.list(null);
assertThat((String) commandResult, CoreMatchers.containsString("app register"));
assertThat((String) commandResult, CoreMatchers.containsString("app import"));
}
示例14: setUp
import org.springframework.hateoas.PagedResources; //導入方法依賴的package包/類
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
when(dataFlowOperations.runtimeOperations()).thenReturn(runtimeOperations);
DataFlowShell dataFlowShell = new DataFlowShell();
dataFlowShell.setDataFlowOperations(dataFlowOperations);
this.runtimeCommands = new RuntimeCommands(dataFlowShell);
appStatusResource1 = new AppStatusResource("1", "deployed");
Map<String, String> properties = new HashMap<>();
properties.put("key1", "value1");
properties.put("key2", "value1");
AppInstanceStatusResource instanceStatusResource1 = new AppInstanceStatusResource("10", "deployed", properties);
AppInstanceStatusResource instanceStatusResource2 = new AppInstanceStatusResource("20", "deployed", null);
List<AppInstanceStatusResource> instanceStatusResources1 = new ArrayList<>();
instanceStatusResources1.add(instanceStatusResource1);
instanceStatusResources1.add(instanceStatusResource2);
PagedResources.PageMetadata metadata1 = new PagedResources.PageMetadata(instanceStatusResources1.size(), 1,
instanceStatusResources1.size(), 1);
PagedResources<AppInstanceStatusResource> resources = new PagedResources<>(instanceStatusResources1, metadata1);
appStatusResource1.setInstances(resources);
appStatusResource2 = new AppStatusResource("2", "undeployed");
AppInstanceStatusResource instanceStatusResource3 = new AppInstanceStatusResource("30", "undeployed", null);
AppInstanceStatusResource instanceStatusResource4 = new AppInstanceStatusResource("40", "undeployed", null);
List<AppInstanceStatusResource> instanceStatusResources2 = new ArrayList<>();
instanceStatusResources1.add(instanceStatusResource3);
instanceStatusResources1.add(instanceStatusResource4);
PagedResources.PageMetadata metadata3 = new PagedResources.PageMetadata(instanceStatusResources2.size(), 1,
instanceStatusResources2.size(), 1);
PagedResources<AppInstanceStatusResource> resources2 = new PagedResources<>(instanceStatusResources2,
metadata3);
appStatusResource2.setInstances(resources2);
appStatusResource3 = new AppStatusResource("3", "failed");
AppInstanceStatusResource instanceStatusResource5 = new AppInstanceStatusResource("50", "failed", null);
AppInstanceStatusResource instanceStatusResource6 = new AppInstanceStatusResource("60", "deployed", null);
List<AppInstanceStatusResource> instanceStatusResources3 = new ArrayList<>();
instanceStatusResources1.add(instanceStatusResource5);
instanceStatusResources1.add(instanceStatusResource6);
PagedResources.PageMetadata metadata4 = new PagedResources.PageMetadata(instanceStatusResources3.size(), 1,
instanceStatusResources3.size(), 1);
PagedResources<AppInstanceStatusResource> resources3 = new PagedResources<>(instanceStatusResources3,
metadata4);
appStatusResource3.setInstances(resources3);
}