private void prepareCallWithEmptyResults() throws IOException { WsTestUtil.mockStream(wsClient, createStreamOfProfiles()); }
private void prepareCallWithResults() throws IOException { WsTestUtil.mockStream(wsClient, createStreamOfProfiles("qp")); }
@Test public void loadDefault_sets_organization_parameter_if_defined_in_settings() throws IOException { when(properties.organizationKey()).thenReturn(Optional.of("my-org")); WsTestUtil.mockStream(wsClient, "/api/qualityprofiles/search.protobuf?defaults=true&organization=my-org", createStreamOfProfiles("qp")); WsTestUtil.mockStream(wsClient, "/api/qualityprofiles/search.protobuf?profileName=foo&organization=my-org", createStreamOfProfiles("qp")); underTest.loadDefault("foo"); verifyCalledPath("/api/qualityprofiles/search.protobuf?defaults=true&organization=my-org"); verifyCalledPath("/api/qualityprofiles/search.protobuf?profileName=foo&organization=my-org"); }
@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"); }
@Test public void loadDefault_gets_profiles_with_specified_name() throws IOException { WsTestUtil.mockStream(wsClient, "/api/qualityprofiles/search.protobuf?defaults=true", createStreamOfProfiles("qp")); WsTestUtil.mockStream(wsClient, "/api/qualityprofiles/search.protobuf?profileName=foo", createStreamOfProfiles("qp")); underTest.loadDefault("foo"); verifyCalledPath("/api/qualityprofiles/search.protobuf?defaults=true"); verifyCalledPath("/api/qualityprofiles/search.protobuf?profileName=foo"); }