### Question:
DefaultRestrictionPolicy implements RestrictionPolicy { @Override public boolean restrictedEndpoint(final HttpServerExchange exchange, final String containerId) { final String relativePath = exchange.getRelativePath(); final boolean isReadOnlyRequest = isGet(exchange.getRequestMethod()); final boolean isContainerResource = relativePath.endsWith("/containers/" + containerId); final boolean isScannerResource = relativePath.endsWith("/scanner"); final boolean isReleaseIdResource = relativePath.endsWith("/release-id"); if (!isReadOnlyRequest && (isContainerResource || isScannerResource || isReleaseIdResource)) { return true; } return false; }  @Override boolean restrictedEndpoint(final HttpServerExchange exchange,
                                      final String containerId); @Override String toString();  }### Answer:
@Test public void testRestrictedEndpointWhenEndpointIsNotRestricted() { final HttpServerExchange exchange = makeHttpServerExchange("/containers/containerId", "GET"); final String containerId = "containerId"; final boolean isRestricted = restrictionPolicy.restrictedEndpoint(exchange, containerId); assertFalse(isRestricted); }
@Test public void testRestrictedEndpointWhenRequestMethodIsNotGET() { final HttpServerExchange exchange = makeHttpServerExchange("/containers/containerId", "POST"); final String containerId = "containerId"; final boolean isRestricted = restrictionPolicy.restrictedEndpoint(exchange, containerId); assertTrue(isRestricted); }
@Test public void testRestrictedEndpointWhenRelativePathEndsWithContainerId() { final HttpServerExchange exchange = makeHttpServerExchange("/scanner", "POST"); final String containerId = "containerId"; final boolean isRestricted = restrictionPolicy.restrictedEndpoint(exchange, containerId); assertTrue(isRestricted); }
@Test public void testRestrictedEndpointWhenRelativePathEndsWithReleaseId() { final HttpServerExchange exchange = makeHttpServerExchange("/release-id", "POST"); final String containerId = "containerId"; final boolean isRestricted = restrictionPolicy.restrictedEndpoint(exchange, containerId); assertTrue(isRestricted); }