@Test public void testAddChunk() { final ChunkContainer container = createFilledChunk(); long position = container.getChunks().size() + 1; for (GUID curr : GUID.KNOWN_GUIDS) { try { container .addChunk(new Chunk(curr, position++, BigInteger.ZERO)); if (!curr.equals(GUID.GUID_STREAM)) { Assert.fail("Only stream chunks may be added multiple times."); } } catch (IllegalArgumentException iae) { } } Assert.assertTrue(ChunkContainer.chunkstartsUnique(container)); try { container.addChunk(new Chunk(GUID.GUID_STREAM, 0, BigInteger.ZERO)); } catch (AssertionError ae) { } Assert.assertFalse(ChunkContainer.chunkstartsUnique(container)); }
public void addChunk(final Chunk toAdd) { final List<Chunk> list = assertChunkList(toAdd.getGuid()); if (!list.isEmpty() && !MULTI_CHUNKS.contains(toAdd.getGuid())) { throw new IllegalArgumentException("The GUID of the given chunk indicates, that there is no more instance allowed."); } list.add(toAdd); assert chunkstartsUnique(this) : "Chunk has equal start position like an already inserted one."; }
ChunkContainer extends Chunk { public void addChunk(final Chunk toAdd) { final List<Chunk> list = assertChunkList(toAdd.getGuid()); if (!list.isEmpty() && !MULTI_CHUNKS.contains(toAdd.getGuid())) { throw new IllegalArgumentException("The GUID of the given chunk indicates, that there is no more instance allowed."); } list.add(toAdd); assert chunkstartsUnique(this) : "Chunk has equal start position like an already inserted one."; } }
ChunkContainer extends Chunk { public void addChunk(final Chunk toAdd) { final List<Chunk> list = assertChunkList(toAdd.getGuid()); if (!list.isEmpty() && !MULTI_CHUNKS.contains(toAdd.getGuid())) { throw new IllegalArgumentException("The GUID of the given chunk indicates, that there is no more instance allowed."); } list.add(toAdd); assert chunkstartsUnique(this) : "Chunk has equal start position like an already inserted one."; } ChunkContainer(final GUID chunkGUID, final long pos, final BigInteger length); }
ChunkContainer extends Chunk { public void addChunk(final Chunk toAdd) { final List<Chunk> list = assertChunkList(toAdd.getGuid()); if (!list.isEmpty() && !MULTI_CHUNKS.contains(toAdd.getGuid())) { throw new IllegalArgumentException("The GUID of the given chunk indicates, that there is no more instance allowed."); } list.add(toAdd); assert chunkstartsUnique(this) : "Chunk has equal start position like an already inserted one."; } ChunkContainer(final GUID chunkGUID, final long pos, final BigInteger length); void addChunk(final Chunk toAdd); Collection<Chunk> getChunks(); boolean hasChunkByGUID(final GUID lookFor); @Override String prettyPrint(final String prefix); String prettyPrint(final String prefix, final String containerInfo); }
ChunkContainer extends Chunk { public void addChunk(final Chunk toAdd) { final List<Chunk> list = assertChunkList(toAdd.getGuid()); if (!list.isEmpty() && !MULTI_CHUNKS.contains(toAdd.getGuid())) { throw new IllegalArgumentException("The GUID of the given chunk indicates, that there is no more instance allowed."); } list.add(toAdd); assert chunkstartsUnique(this) : "Chunk has equal start position like an already inserted one."; } ChunkContainer(final GUID chunkGUID, final long pos, final BigInteger length); void addChunk(final Chunk toAdd); Collection<Chunk> getChunks(); boolean hasChunkByGUID(final GUID lookFor); @Override String prettyPrint(final String prefix); String prettyPrint(final String prefix, final String containerInfo);  }