@Before public void setUp() { NewRelicClient clientMock = mock(NewRelicClient.class); WebTarget webTargetMock = mock(WebTarget.class); Invocation.Builder builderMock = mock(Invocation.Builder.class); when(clientMock.target("/v2/alerts_policies.json")).thenReturn(webTargetMock); when(webTargetMock.queryParam("filter[name]", "policy")).thenReturn(webTargetMock); when(webTargetMock.request(APPLICATION_JSON_TYPE)).thenReturn(builderMock); when(builderMock.get()).thenReturn(responseMock); testee = new DefaultAlertsPoliciesApi(clientMock); }
/** * NewRelic API constructor. * * @param restApiUrl NewRelic REST API URL, for example https://api.newrelic.com * @param syntheticsApiUrl NewRelic Synthetics API URL * @param apiKey API Key for given NewRelic account */ public NewRelicInternalApi(String restApiUrl, String syntheticsApiUrl, String apiKey) { NewRelicClient client = new NewRelicClient(restApiUrl, apiKey); applicationsApi = new DefaultApplicationsApi(client); alertsChannelsApi = new DefaultAlertsChannelsApi(client); alertsPoliciesApi = new DefaultAlertsPoliciesApi(client); alertsConditionsApi = new DefaultAlertsConditionsApi(client); alertsExternalServiceConditionsApi = new DefaultAlertsExternalServiceConditionsApi(client); alertsNrqlConditionsApi = new DefaultAlertsNrqlConditionsApi(client); alertsSyntheticsConditionApi = new DefaultAlertsSyntheticsConditionsApi(client); keyTransactionsApi = new DefaultKeyTransactionsApi(client); deploymentsApi = new DefaultDeploymentsApi(client); serversApi = new DefaultServersApi(client); usersApi = new DefaultUsersApi(client); NewRelicClient syntheticsClient = new NewRelicClient(syntheticsApiUrl, apiKey); syntheticsMonitorsApi = new DefaultSyntheticsMonitorsApi(syntheticsClient); } }