JsonFileBasedLoader extends AbstractLoader<T> { protected int indexOf(byte[] file, byte[] occurence) { if (file != null && occurence != null) { int len = occurence.length; int limit = file.length - len; for (int i = 0; i <= limit; i++) { int k = 0; for (; k < len; k++) { if (occurence[k] != file[i + k]) { break; } } if (k == len) { return i; } } } return -1; } JsonFileBasedLoader(JacksonObjectMapper objectMapper, Class<T> type); @Override List<T> findByObjectId(Path directory, String objectId); @Override Map<String, List<T>> findByObjectIds(Path directory, List<String> objectIds); @Override T getByUUID(Path directory, String uuid); @Override boolean contains(Path directory, String objectId);  }
@Test public void should_find_a_byte_array_in_an_another() { assertThat(loader.indexOf("mon exemple complet".getBytes(), "exem".getBytes())).isEqualTo(4); }
@Test public void should_find_a_byte_array_in_an_another_on_start_position() { assertThat(loader.indexOf("mon exemple complet".getBytes(), "mon ex".getBytes())).isEqualTo(0); }
@Test public void should_not_find_a_byte_array_in_an_another() { assertThat(loader.indexOf("mon exemple complet".getBytes(), "rex".getBytes())).isEqualTo(-1); }
@Test public void should_not_find_null_in_byte_array() { assertThat(loader.indexOf("mon exemple complet".getBytes(), null)).isEqualTo(-1); }
@Test public void should_not_find_occurence_in_byte_array_null() { assertThat(loader.indexOf(null, "search".getBytes())).isEqualTo(-1); }