@Test public void load_sets_organization_parameter_if_defined_in_settings() throws IOException { when(properties.organizationKey()).thenReturn(Optional.of("my-org")); prepareCallWithResults(); underTest.load("foo", null); verifyCalledPath("/api/qualityprofiles/search.protobuf?projectKey=foo&organization=my-org"); }
@Test public void load_throws_MessageException_if_no_profiles_are_available_for_specified_project() throws IOException { prepareCallWithEmptyResults(); exception.expect(MessageException.class); exception.expectMessage("No quality profiles"); underTest.load("project", null); verifyNoMoreInteractions(wsClient); }
@Test public void load_gets_all_profiles_for_specified_project() throws IOException { prepareCallWithResults(); underTest.load("foo", null); verifyCalledPath("/api/qualityprofiles/search.protobuf?projectKey=foo"); }
@Test public void load_throws_MessageException_if_organization_is_not_found() throws IOException { HttpException e = new HttpException("", 404, "{\"errors\":[{\"msg\":\"No organization with key 'myorg'\"}]}"); WsTestUtil.mockException(wsClient, e); exception.expect(MessageException.class); exception.expectMessage("Failed to load the quality profiles of project 'project': No organization with key 'myorg'"); underTest.load("project", null); verifyNoMoreInteractions(wsClient); }
@Test public void load_gets_profiles_for_specified_project_and_profile_name() throws IOException { WsTestUtil.mockStream(wsClient, "/api/qualityprofiles/search.protobuf?projectKey=foo", createStreamOfProfiles("qp")); WsTestUtil.mockStream(wsClient, "/api/qualityprofiles/search.protobuf?profileName=bar", createStreamOfProfiles("qp")); underTest.load("foo", "bar"); verifyCalledPath("/api/qualityprofiles/search.protobuf?projectKey=foo"); verifyCalledPath("/api/qualityprofiles/search.protobuf?profileName=bar"); }
@Test public void load_encodes_url_parameters() throws IOException { WsTestUtil.mockStream(wsClient, "/api/qualityprofiles/search.protobuf?projectKey=foo%232", createStreamOfProfiles("qp")); WsTestUtil.mockStream(wsClient, "/api/qualityprofiles/search.protobuf?profileName=bar%232", createStreamOfProfiles("qp")); underTest.load("foo#2", "bar#2"); verifyCalledPath("/api/qualityprofiles/search.protobuf?projectKey=foo%232"); verifyCalledPath("/api/qualityprofiles/search.protobuf?profileName=bar%232"); }