protected List<MavenArtifact> processResponse(Dependency dependency, HttpURLConnection conn) throws IOException {
        final List<MavenArtifact> result = new ArrayList<>();

        try (InputStreamReader streamReader = new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8);
                JsonParser parser = objectReader.getFactory().createParser(streamReader)) {

            if (init(parser) && parser.nextToken() == com.fasterxml.jackson.core.JsonToken.START_OBJECT) {
                // at least one result
                do {
                    final FileImpl file = objectReader.readValue(parser);

                    checkHashes(dependency, file.getChecksums());

                    final Matcher pathMatcher = PATH_PATTERN.matcher(file.getPath());
                    if (!pathMatcher.matches()) {
                        throw new IllegalStateException("Cannot extract the Maven information from the path "
                                + "retrieved in Artifactory " + file.getPath());
                    }

                    final String groupId = pathMatcher.group("groupId").replace('/', '.');
                    final String artifactId = pathMatcher.group("artifactId");
                    final String version = pathMatcher.group("version");

                    result.add(new MavenArtifact(groupId, artifactId, version, file.getDownloadUri(),
                            MavenArtifact.derivePomUrl(artifactId, version, file.getDownloadUri())));

                } while (parser.nextToken() == com.fasterxml.jackson.core.JsonToken.START_OBJECT);
            } else {
                throw new FileNotFoundException("Artifact " + dependency + " not found in Artifactory");
            }
        }

        return result;
    }
@Test
    public void shouldProcessCorrectlyArtifactoryAnswerWithMultipleMatches() throws IOException {
        // Given
        Dependency dependency = new Dependency();
        dependency.setSha1sum("94a9ce681a42d0352b3ad22659f67835e560d107");
        dependency.setMd5sum("03dcfdd88502505cc5a805a128bfdd8d");
        final HttpURLConnection urlConnection = mock(HttpURLConnection.class);
        final byte[] payload = multipleMatchesPayload();
        when(urlConnection.getInputStream()).thenReturn(new ByteArrayInputStream(payload));

        // When
        final List<MavenArtifact> mavenArtifacts = searcher.processResponse(dependency, urlConnection);

        // Then

        assertEquals(2, mavenArtifacts.size());
        final MavenArtifact artifact1 = mavenArtifacts.get(0);
        assertEquals("axis", artifact1.getGroupId());
        assertEquals("axis", artifact1.getArtifactId());
        assertEquals("1.4", artifact1.getVersion());
        assertEquals("https://artifactory.techno.ingenico.com/artifactory/gradle-libs-cache/axis/axis/1.4/axis-1.4.jar", artifact1.getArtifactUrl());
        assertEquals("https://artifactory.techno.ingenico.com/artifactory/gradle-libs-cache/axis/axis/1.4/axis-1.4.pom", artifact1.getPomUrl());
        final MavenArtifact artifact2 = mavenArtifacts.get(1);
        assertEquals("org.apache.axis", artifact2.getGroupId());
        assertEquals("axis", artifact2.getArtifactId());
        assertEquals("1.4", artifact2.getVersion());
        assertEquals("https://artifactory.techno.ingenico.com/artifactory/gradle-libs-cache/org/apache/axis/axis/1.4/axis-1.4.jar", artifact2.getArtifactUrl());
        assertEquals("https://artifactory.techno.ingenico.com/artifactory/gradle-libs-cache/org/apache/axis/axis/1.4/axis-1.4.pom", artifact2.getPomUrl());
    }