MetadataKeysBuilder { protected Set<MetadataKey> getMetadataKeys( JsonNode openAPISpecJsonNode, String operation) { Set<MetadataKey> metadataKeys = new HashSet<>(); JsonNode pathsJsonNode = openAPISpecJsonNode.get(OASConstants.PATHS); Iterator<Map.Entry<String, JsonNode>> pathsIterator = pathsJsonNode.fields(); while (pathsIterator.hasNext()) { Map.Entry<String, JsonNode> pathEntry = pathsIterator.next(); JsonNode pathJsonNode = pathEntry.getValue(); if (pathJsonNode.has(operation)) { String path = pathEntry.getKey(); MetadataKeyBuilder metadataKeyBuilder = MetadataKeyBuilder.newKey(path); metadataKeys.add(metadataKeyBuilder.build()); } } return metadataKeys; }  Set<MetadataKey> buildMetadataKeys(
			MetadataContext metadataContext, String operation);  }
@Test public void testBuildDELETEEndpointMetadataKeys() { MetadataKeysBuilder metadataKeysBuilder = new MetadataKeysBuilder(); Set<String> metadataKeyIds = toMetadataKeyIdSet( metadataKeysBuilder.getMetadataKeys( openAPISpecJsonNode, OASConstants.OPERATION_DELETE)); Assert.assertTrue( metadataKeyIds.contains("/endpoint/with/delete/and/get/operation")); }
@Test public void testBuildEmptyMetadataKeys() { MetadataKeysBuilder metadataKeysBuilder = new MetadataKeysBuilder(); Set<MetadataKey> metadataKeys = metadataKeysBuilder.getMetadataKeys( openAPISpecJsonNode, OPERATION_HEAD); Assert.assertTrue(metadataKeys.isEmpty()); }
@Test public void testBuildGETEndpointMetadataKeys() { MetadataKeysBuilder metadataKeysBuilder = new MetadataKeysBuilder(); Set<String> metadataKeyIds = toMetadataKeyIdSet( metadataKeysBuilder.getMetadataKeys( openAPISpecJsonNode, OASConstants.OPERATION_GET)); Assert.assertTrue( metadataKeyIds.contains("/endpoint/with/delete/and/get/operation")); Assert.assertTrue( metadataKeyIds.contains("/endpoint/with/get/and/patch/operation")); Assert.assertTrue( metadataKeyIds.contains("/endpoint/with/get/and/post/operation")); }
@Test public void testBuildPATCHEndpointMetadataKeys() { MetadataKeysBuilder metadataKeysBuilder = new MetadataKeysBuilder(); Set<String> metadataKeyIds = toMetadataKeyIdSet( metadataKeysBuilder.getMetadataKeys( openAPISpecJsonNode, OASConstants.OPERATION_PATCH)); Assert.assertTrue( metadataKeyIds.contains("/endpoint/with/get/and/patch/operation")); }
@Test public void testBuildPOSTEndpointMetadataKeys() { MetadataKeysBuilder metadataKeysBuilder = new MetadataKeysBuilder(); Set<String> metadataKeyIds = toMetadataKeyIdSet( metadataKeysBuilder.getMetadataKeys( openAPISpecJsonNode, OASConstants.OPERATION_POST)); Assert.assertTrue( metadataKeyIds.contains("/endpoint/with/get/and/post/operation")); }