Package com.aconex.scrutineer

Examples of com.aconex.scrutineer.IdAndVersion


    }

    boolean writeSearchResponseToOutputStream(ObjectOutputStream objectOutputStream, SearchResponse searchResponse) throws IOException {
        SearchHit[] hits = searchResponse.getHits().hits();
        for (SearchHit hit : hits) {
            new IdAndVersion(hit.getId(), hit.getVersion()).writeToStream(objectOutputStream);
            numItems++;
        }
        return hits.length > 0;
    }
View Full Code Here


    @SuppressWarnings("PMD.NcssMethodCount")
    private void nextRow() {
        try {
            if (resultSet.next()) {
                current = new IdAndVersion(resultSet.getString(1), getVersionValueAnLong());
            } else {
                current = null;
            }
        } catch (SQLException e) {
            throw new RuntimeException(e);
View Full Code Here

    }

    boolean writeSearchResponseToOutputStream(ObjectOutputStream objectOutputStream, SearchResponse searchResponse) throws IOException {
        SearchHit[] hits = searchResponse.getHits().hits();
        for (SearchHit hit : hits) {
            new IdAndVersion(hit.getId(), hit.getVersion()).writeToStream(objectOutputStream);
            numItems++;
        }
        return hits.length > 0;
    }
View Full Code Here

      parallelOpenStreamsAndWait(primaryStream, secondayStream);

      Iterator<IdAndVersion> primaryIterator = primaryStream.iterator();
      Iterator<IdAndVersion> secondaryIterator = secondayStream.iterator();

      IdAndVersion primaryItem = next(primaryIterator);
      IdAndVersion secondaryItem = next(secondaryIterator);

      while (primaryItem != null && secondaryItem != null) {
        if (primaryItem.equals(secondaryItem)) {
          primaryItem = verifiedNext(primaryIterator, primaryItem);
          secondaryItem = next(secondaryIterator);
        } else if (primaryItem.getId().equals(secondaryItem.getId())) {
          idAndVersionStreamVerifierListener.onVersionMisMatch(primaryItem, secondaryItem);
          primaryItem = verifiedNext(primaryIterator, primaryItem);
          secondaryItem = next(secondaryIterator);
        } else if (primaryItem.compareTo(secondaryItem) < 0) {
          idAndVersionStreamVerifierListener.onMissingInSecondaryStream(primaryItem);
View Full Code Here

    }
  }

  private IdAndVersion verifiedNext(Iterator<IdAndVersion> iterator, IdAndVersion previous) {
    if (iterator.hasNext()) {
      IdAndVersion next = iterator.next();
      if (next == null) {
        throw new IllegalStateException("primary stream must not return null");
      } else if (previous.compareTo(next) > 0) {
        throw new IllegalStateException("primary stream not ordered as expected: " + next + " followed "
            + previous);
View Full Code Here

    }

    boolean writeSearchResponseToOutputStream(ObjectOutputStream objectOutputStream, SearchResponse searchResponse) throws IOException {
        SearchHit[] hits = searchResponse.getHits().hits();
        for (SearchHit hit : hits) {
            new IdAndVersion(hit.getId(), hit.getVersion()).writeToStream(objectOutputStream);
            numItems++;
        }
        return hits.length > 0;
    }
View Full Code Here

    @Test
    public void shouldReadNextIdAndVersionObjectFromStream() throws IOException {
        when(objectInputStream.readUTF()).thenReturn(ID);
        when(objectInputStream.readLong()).thenReturn(VERSION);
        IdAndVersion idAndVersion = idAndVersionDataReader.readNext();
        assertThat(idAndVersion.getId(), is(ID));
        assertThat(idAndVersion.getVersion(), is(VERSION));
    }
View Full Code Here

        assertThat(idAndVersionInputStreamIterator.hasNext(), is(true));
    }

    @Test
    public void shouldGetTheNextItem() throws IOException {
        IdAndVersion idAndVersion = new StringIdAndVersion(ID, VERSION);
        when(idAndVersionDataReader.readNext()).thenReturn(idAndVersion);
        IdAndVersionInputStreamIterator idAndVersionInputStreamIterator = new IdAndVersionInputStreamIterator(idAndVersionDataReader);
        assertThat(idAndVersionInputStreamIterator.next(), is(idAndVersion));
    }
View Full Code Here

        assertThat(idAndVersionInputStreamIterator.next(), is(idAndVersion));
    }

    @Test
    public void hasNextShouldReturnFalseAtEndOfTheStream() throws IOException {
      IdAndVersion idAndVersion = new StringIdAndVersion(ID, VERSION);
        when(idAndVersionDataReader.readNext()).thenReturn(idAndVersion).thenReturn(null);
        IdAndVersionInputStreamIterator idAndVersionInputStreamIterator = new IdAndVersionInputStreamIterator(idAndVersionDataReader);
        assertThat(idAndVersionInputStreamIterator.next(), is(idAndVersion));
        assertThat(idAndVersionInputStreamIterator.hasNext(), is(false));
    }
View Full Code Here

    }

    @Override
    public IdAndVersion next() {
        try {
            IdAndVersion result = currentValue;
            currentValue = idAndVersionDataReader.readNext();
            return result;
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
View Full Code Here

TOP

Related Classes of com.aconex.scrutineer.IdAndVersion

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.