Fixes NPE in HgConfigPackageResource for non-existing packages.

This commit is contained in:
Johannes Schnatterer
2018-08-07 10:44:18 +02:00
parent 869821f6db
commit adde70f090
2 changed files with 13 additions and 9 deletions

View File

@@ -152,10 +152,11 @@ public class HgConfigPackageResourceTest {
@Test
@SubjectAware(username = "writeOnly")
public void shouldHandleMissingPackageId() throws Exception {
MockHttpResponse response = put(null);
assertEquals(HttpServletResponse.SC_METHOD_NOT_ALLOWED, response.getStatus());
public void shouldHandlePackagesThatAreNotFound() throws Exception {
String packageId = "this-package-does-not-ex";
when(hgPackageReader.getPackage(packageId)).thenReturn(null);
MockHttpResponse response = put(packageId);
assertEquals(HttpServletResponse.SC_NOT_FOUND, response.getStatus());
}
@Test