@Before public void setEdm() throws ODataException { edm = MockFacade.getMockEdm(); }
private List<PathSegment> mockPathSegments( final UriType uriType, final boolean moreNavigation, final boolean isValue) { List<String> segments = new ArrayList<String>(); if (uriType == UriType.URI1 || uriType == UriType.URI15) { if (moreNavigation) { segments.add("Managers('1')"); segments.add("nm_Employees"); } else { segments.add("Employees"); } } else if (uriType == UriType.URI2 || uriType == UriType.URI3 || uriType == UriType.URI4 || uriType == UriType.URI5 || uriType == UriType.URI16 || uriType == UriType.URI17) { if (moreNavigation) { segments.add("Managers('1')"); segments.add("nm_Employees('1')"); } else { segments.add("Employees('1')"); } } else if (uriType == UriType.URI6A || uriType == UriType.URI7A || uriType == UriType.URI50A) { segments.add("Managers('1')"); if (moreNavigation) { segments.add("nm_Employees('1')"); segments.add("ne_Manager"); } if (uriType == UriType.URI7A || uriType == UriType.URI50A) { segments.add("$links"); } segments.add("nm_Employees('1')"); } else if (uriType == UriType.URI6B || uriType == UriType.URI7B || uriType == UriType.URI50B) { segments.add("Managers('1')"); if (moreNavigation) { segments.add("nm_Employees('1')"); segments.add("ne_Manager"); } if (uriType == UriType.URI7B || uriType == UriType.URI50B) { segments.add("$links"); } segments.add("nm_Employees"); } else if (uriType == UriType.URI8) { segments.add("$metadata"); } else if (uriType == UriType.URI9) { segments.add("$batch"); } else if (uriType == UriType.URI10) { segments.add("OldestEmployee"); } else if (uriType == UriType.URI11) { segments.add("AllLocations"); } else if (uriType == UriType.URI12) { segments.add("MostCommonLocation"); } else if (uriType == UriType.URI13) { segments.add("AllUsedRoomIds"); } else if (uriType == UriType.URI14) { segments.add("MaximalAge"); } if (uriType == UriType.URI3 || uriType == UriType.URI4) { segments.add("Location"); } if (uriType == UriType.URI4) { segments.add("Country"); } else if (uriType == UriType.URI5) { segments.add("EmployeeName"); } if (uriType == UriType.URI15 || uriType == UriType.URI16 || uriType == UriType.URI50A || uriType == UriType.URI50B) { segments.add("$count"); } if (uriType == UriType.URI17 || isValue) { segments.add("$value"); } // self-test try { final UriInfoImpl uriInfo = (UriInfoImpl) UriParser.parse( edm, MockFacade.getPathSegmentsAsODataPathSegmentMock(segments), Collections.<String, String>emptyMap()); assertEquals(uriType, uriInfo.getUriType()); assertEquals(uriType == UriType.URI17 || isValue, uriInfo.isValue()); } catch (final ODataException e) { fail(); } List<PathSegment> pathSegments = new ArrayList<PathSegment>(); for (final String segment : segments) { pathSegments.add(mockPathSegment(segment)); } return pathSegments; }