DiscoveryService extends EndpointService { public List<MetricSchemaRecord> getMatchingRecords(String namespaceRegex, String scopeRegex, String metricRegex, String tagKeyRegex, String tagValueRegex, int limit) throws IOException, TokenExpiredException { StringBuilder urlBuilder = _buildBaseUrl(namespaceRegex, scopeRegex, metricRegex, tagKeyRegex, tagValueRegex, limit); String requestUrl = urlBuilder.toString(); ArgusResponse response = getClient().executeHttpRequest(ArgusHttpClient.RequestType.GET, requestUrl, null); assertValidResponse(response, requestUrl); return fromJson(response.getResult(), new TypeReference<List<MetricSchemaRecord>>() { }); } DiscoveryService(ArgusHttpClient client); List<MetricSchemaRecord> getMatchingRecords(String namespaceRegex, String scopeRegex, String metricRegex, String tagKeyRegex,
        String tagValueRegex, int limit); List<String> getMatchingRecordFields(String namespaceRegex, String scopeRegex, String metricRegex, String tagKeyRegex,
        String tagValueRegex, FieldSelector type, int limit); MetricDiscoveryResult getMatchingRecords(MetricDiscoveryQuery query);  }
@Test public void testGetMatchingRecords_GET() throws IOException, TokenExpiredException { try(ArgusService argusService = new ArgusService(getMockedClient("/DiscoveryServiceTest.json"))) { DiscoveryService discoveryService = argusService.getDiscoveryService(); List<MetricSchemaRecord> result = discoveryService.getMatchingRecords("nsReg", "scpReg", "metReg", "tkReg", "tvReg", 1); List<MetricSchemaRecord> expected = Arrays.asList(new MetricSchemaRecord[] { _constructPersistedMetricSchemaRecord() }); assertEquals(expected, result); } }
@Test public void testGetMatchingRecords_POST() throws IOException, TokenExpiredException { try(ArgusService argusService = new ArgusService(getMockedClient("/DiscoveryServiceTest.json"))) { DiscoveryService discoveryService = argusService.getDiscoveryService(); MetricDiscoveryQuery query = new MetricDiscoveryQuery(null, "scpReg", "*", null, null, 10, null, null); MetricDiscoveryResult result = discoveryService.getMatchingRecords(query); MetricDiscoveryResult expected = new MetricDiscoveryResult( Arrays.asList(new MetricSchemaRecord[] { _constructPersistedMetricSchemaRecord() }), null); assertEquals(expected, result); } }
@Test public void testGetMatchingRecordFields_POST() throws IOException, TokenExpiredException { try(ArgusService argusService = new ArgusService(getMockedClient("/DiscoveryServiceTest.json"))) { DiscoveryService discoveryService = argusService.getDiscoveryService(); MetricDiscoveryQuery query = new MetricDiscoveryQuery(null, "scpReg", "*", null, null, 10, "namespace", null); MetricDiscoveryResult result = discoveryService.getMatchingRecords(query); MetricDiscoveryResult expected = new MetricDiscoveryResult(Arrays.asList(new String[] { "namespace1", "namespace2" }), null); assertEquals(expected, result); } }