### Question:
GeoGigDataStore extends ContentDataStore implements DataStore { public Optional<ObjectId> createOrUpdateIndex(String layerName, String... extraAttributes) { String head = getOrFigureOutHead(); return createOrUpdateIndex(this.repository, head, layerName, extraAttributes); } GeoGigDataStore(@NonNull Repository repository);  GeoGigDataStore(@NonNull Context context); @Override void dispose(); void setCloseOnDispose(boolean close); boolean isCloseOnDispose(); void setHead(@Nullable final String refspec); String getOrFigureOutHead(); @Nullable String getConfiguredHead(); boolean isAllowTransactions(); @Nullable String getCheckedOutBranch(); Context resolveContext(@Nullable Transaction transaction); org.opengis.feature.type.Name getDescriptorName(@NonNull NodeRef treeRef); NodeRef findTypeRef(@NonNull Name typeName, @Nullable Transaction tx); GeogigFeatureStore getFeatureStore(String typeName); @Override void createSchema(SimpleFeatureType featureType); @Override void removeSchema(Name name); @Override void removeSchema(String name); GeogigDiffFeatureSource getDiffFeatureSource(final String typeName, final String oldRoot); GeogigDiffFeatureSource getDiffFeatureSource(final String typeName, final String oldRoot,
            final ChangeType changeType); GeogigDiffFeatureSource getDiffFeatureSource(final String typeName, final String oldRoot,
            final Context oldContext, final ChangeType changeType); Optional<ObjectId> createOrUpdateIndex(String layerName, String... extraAttributes); static Optional<ObjectId> createOrUpdateIndex(Repository repository,
            @Nullable String branchOrHead, String featureTreePath, String... extraAttributes);  }### Answer:
@Test public void testCreateOrUpdateIndex() throws Exception { insertAndAdd(lines1); commit(); IndexInfo createOrUpdateIndex = createOrUpdateIndexAndVerify(linesName, new String[] {}) .get(); ObjectId id = createOrUpdateIndex.getId(); Set<String> materializedAttributeNames = IndexInfo .getMaterializedAttributeNames(createOrUpdateIndex); assertTrue("There should be no extra attributes for the Index", materializedAttributeNames.isEmpty()); createOrUpdateIndex = createOrUpdateIndexAndVerify(linesName, new String[] { "sp" }).get(); ObjectId secondId = createOrUpdateIndex.getId(); assertEquals("Index does not match", id, secondId); verifyExtraAttributes(createOrUpdateIndex, new String[] { "sp" }); createOrUpdateIndex = createOrUpdateIndexAndVerify(linesName, new String[] { "sp" }).get(); ObjectId thirdId = createOrUpdateIndex.getId(); assertEquals("Index does not match", id, thirdId); verifyExtraAttributes(createOrUpdateIndex, new String[] { "sp" }); createOrUpdateIndex = createOrUpdateIndexAndVerify(linesName, new String[] { "sp", "ip" }) .get(); ObjectId fourthId = createOrUpdateIndex.getId(); assertEquals("Index does not match", id, fourthId); verifyExtraAttributes(createOrUpdateIndex, new String[] { "ip", "sp" }); createOrUpdateIndex = createOrUpdateIndexAndVerify(linesName, new String[] { "ip" }).get(); ObjectId fifthId = createOrUpdateIndex.getId(); assertEquals("Index does not match", id, fifthId); verifyExtraAttributes(createOrUpdateIndex, new String[] { "sp", "ip" }); createOrUpdateIndex = createOrUpdateIndexAndVerify(linesName, new String[] {}).get(); ObjectId sixthId = createOrUpdateIndex.getId(); assertEquals("Index does not match", id, sixthId); verifyExtraAttributes(createOrUpdateIndex, new String[] { "ip", "sp" }); }