### Question:
EndpointMutator { protected String getResourceVersion(List<PathSegment> segments, MutatedContainer mutated) { String version = segments.get(0).getPath(); if (mutated.getPath() != null && mutated.getPath().startsWith("/" + ResourceNames.SEARCH + "/") && VERSION_1_0.equals(version)) { return VERSION_1_1; } return version; }  void mutateURI(Authentication auth, ContainerRequest request);  }### Answer:
@Test public void testGetResourceVersionForSearch() { List<PathSegment> segments = getPathSegmentList("v1/search"); MutatedContainer mutated = mock(MutatedContainer.class); when(mutated.getPath()).thenReturn("/search"); assertEquals("Should match", "v1", endpointMutator.getResourceVersion(segments, mutated)); segments = getPathSegmentList("v1.0/search"); assertEquals("Should match", "v1.0", endpointMutator.getResourceVersion(segments, mutated)); segments = getPathSegmentList("v1.1/search"); assertEquals("Should match", "v1.1", endpointMutator.getResourceVersion(segments, mutated)); segments = getPathSegmentList("v1.3/search"); assertEquals("Should match", "v1.3", endpointMutator.getResourceVersion(segments, mutated)); }
@Test public void testGetResourceVersion() { List<PathSegment> segments = getPathSegmentList("v1/students"); MutatedContainer mutated = mock(MutatedContainer.class); when(mutated.getPath()).thenReturn("/studentSectionAssociations/1234/students"); assertEquals("Should match", "v1", endpointMutator.getResourceVersion(segments, mutated)); segments = getPathSegmentList("v1.0/students"); assertEquals("Should match", "v1.0", endpointMutator.getResourceVersion(segments, mutated)); segments = getPathSegmentList("v1.1/students"); assertEquals("Should match", "v1.1", endpointMutator.getResourceVersion(segments, mutated)); segments = getPathSegmentList("v1.3/students"); assertEquals("Should match", "v1.3", endpointMutator.getResourceVersion(segments, mutated)); segments = getPathSegmentList("v1.1/students"); when(mutated.getPath()).thenReturn(null); assertEquals("Should match", "v1.1", endpointMutator.getResourceVersion(segments, mutated)); }
@Test public void testGetResourceVersionForPublicResources() { List<PathSegment> segments = getPathSegmentList("v1/assessments"); MutatedContainer mutated = mock(MutatedContainer.class); when(mutated.getPath()).thenReturn("/search/assessments"); assertEquals("Should match", "v1", endpointMutator.getResourceVersion(segments, mutated)); segments = getPathSegmentList("v1.0/assessments"); assertEquals("Should match", "v1.1", endpointMutator.getResourceVersion(segments, mutated)); segments = getPathSegmentList("v1.1/assessments"); assertEquals("Should match", "v1.1", endpointMutator.getResourceVersion(segments, mutated)); segments = getPathSegmentList("v1.3/assessments"); assertEquals("Should match", "v1.3", endpointMutator.getResourceVersion(segments, mutated)); }