LeveldbTimelineStore extends AbstractService implements TimelineStore { @VisibleForTesting List<String> getEntityTypes() throws IOException { LeveldbIterator iterator = null; try { iterator = getDbIterator(false); List<String> entityTypes = new ArrayList<String>(); iterator.seek(ENTITY_ENTRY_PREFIX); while (iterator.hasNext()) { byte[] key = iterator.peekNext().getKey(); if (key[0] != ENTITY_ENTRY_PREFIX[0]) { break; } KeyParser kp = new KeyParser(key, ENTITY_ENTRY_PREFIX.length); String entityType = kp.getNextString(); entityTypes.add(entityType); byte[] lookupKey = KeyBuilder.newInstance().add(ENTITY_ENTRY_PREFIX) .add(entityType).getBytesForLookup(); if (lookupKey[lookupKey.length - 1] != 0x0) { throw new IOException("Found unexpected end byte in lookup key"); } lookupKey[lookupKey.length - 1] = 0x1; iterator.seek(lookupKey); } return entityTypes; } catch(DBException e) { throw new IOException(e); } finally { IOUtils.cleanup(LOG, iterator); } } LeveldbTimelineStore(); @Override TimelineEntity getEntity(String entityId, String entityType,
      EnumSet<Field> fields); @Override TimelineEvents getEntityTimelines(String entityType,
      SortedSet<String> entityIds, Long limit, Long windowStart,
      Long windowEnd, Set<String> eventType); @Override TimelineEntities getEntities(String entityType,
      Long limit, Long windowStart, Long windowEnd, String fromId, Long fromTs,
      NameValuePair primaryFilter, Collection<NameValuePair> secondaryFilters,
      EnumSet<Field> fields, CheckAcl checkAcl); @Override TimelinePutResponse put(TimelineEntities entities); @Private @VisibleForTesting TimelinePutResponse putWithNoDomainId(TimelineEntities entities); @Override void put(TimelineDomain domain); @Override TimelineDomain getDomain(String domainId); @Override TimelineDomains getDomains(String owner);  }
@Test public void testGetEntityTypes() throws IOException { List<String> entityTypes = ((LeveldbTimelineStore)store).getEntityTypes(); assertEquals(7, entityTypes.size()); assertEquals("ACL_ENTITY_TYPE_1", entityTypes.get(0)); assertEquals("OLD_ENTITY_TYPE_1", entityTypes.get(1)); assertEquals(entityType1, entityTypes.get(2)); assertEquals(entityType2, entityTypes.get(3)); assertEquals(entityType4, entityTypes.get(4)); assertEquals(entityType5, entityTypes.get(5)); }