use of com.liferay.apio.architect.uri.Path in project com-liferay-apio-architect by liferay.
the class PageTest method testHasPreviousReturnsFalseWhenIsFirst.
@SuppressWarnings("ResultOfMethodCallIgnored")
@Test
public void testHasPreviousReturnsFalseWhenIsFirst() {
Pagination pagination = new Pagination(1, 1);
_path = new Path("name", "id");
Page<String> page = new Page<>("", _pageItems, pagination, _path, emptyList());
assertThat(page.hasPrevious(), is(false));
}
use of com.liferay.apio.architect.uri.Path in project com-liferay-apio-architect by liferay.
the class PathLongIdentifierMapperTest method testMapReturnsLongIfValidPathId.
@Test
public void testMapReturnsLongIfValidPathId() {
Long identifier = _pathIdentifierMapper.map(new Path("name", "42"));
assertThat(identifier, is(42L));
}
use of com.liferay.apio.architect.uri.Path in project com-liferay-apio-architect by liferay.
the class PathStringIdentifierMapperTest method testMapReturnsPath.
@Test
public void testMapReturnsPath() {
Path path = _pathIdentifierMapper.map("name", "id");
assertThat(path.getName(), is("name"));
assertThat(path.getId(), is("id"));
}
use of com.liferay.apio.architect.uri.Path in project com-liferay-apio-architect by liferay.
the class PathStringIdentifierMapperTest method testMapReturnsString.
@Test
public void testMapReturnsString() {
String identifier = _pathIdentifierMapper.map(new Path("name", "id"));
assertThat(identifier, is("id"));
}
use of com.liferay.apio.architect.uri.Path in project com-liferay-apio-architect by liferay.
the class MockWriterUtil method identifierToPath.
/**
* Returns a mock {@link Path} from an identifier. The identifier must be a
* {@link String}, otherwise {@code Optional#empty()} is returned.
*
* @param identifier the identifier
* @return the mock {@code Path} from the identifier, if the identifier is a
* {@code String}; {@code Optional#empty()} otherwise
*/
public static Optional<Path> identifierToPath(String resourceName, Object identifier) {
if (!(identifier instanceof String)) {
return Optional.empty();
}
String string = (String) identifier;
Function<String, Optional<Path>> function = name -> Optional.of(new Path(name, string));
if ("root".equals(resourceName)) {
return function.apply("model");
}
if ("first".equals(resourceName)) {
return function.apply("first-inner-model");
}
if ("second".equals(resourceName)) {
return function.apply("second-inner-model");
}
return function.apply("third-inner-model");
}
Aggregations