use of com.yelp.nrtsearch.server.luceneserver.state.PersistentGlobalState.IndexInfo in project nrtsearch by Yelp.
the class PersistentGlobalStateTest method testUnmodifiableIndices.
@Test(expected = UnsupportedOperationException.class)
public void testUnmodifiableIndices() {
PersistentGlobalState state = new PersistentGlobalState();
state.getIndices().put("test_index", new IndexInfo());
}
use of com.yelp.nrtsearch.server.luceneserver.state.PersistentGlobalState.IndexInfo in project nrtsearch by Yelp.
the class PersistentGlobalStateTest method testBuilder.
@Test
public void testBuilder() {
Map<String, IndexInfo> indicesMap = new HashMap<>();
indicesMap.put("test_index", new IndexInfo());
indicesMap.put("test_index_2", new IndexInfo());
PersistentGlobalState state = new PersistentGlobalState(indicesMap);
PersistentGlobalState rebuilt = state.asBuilder().build();
assertNotSame(state, rebuilt);
assertEquals(state, rebuilt);
indicesMap = new HashMap<>();
indicesMap.put("test_index_3", new IndexInfo());
indicesMap.put("test_index_4", new IndexInfo());
PersistentGlobalState updated = state.asBuilder().withIndices(indicesMap).build();
assertNotEquals(state, updated);
assertEquals(indicesMap, updated.getIndices());
}
use of com.yelp.nrtsearch.server.luceneserver.state.PersistentGlobalState.IndexInfo in project nrtsearch by Yelp.
the class PersistentGlobalStateTest method testGlobalState.
@Test
public void testGlobalState() {
Map<String, IndexInfo> indicesMap = new HashMap<>();
indicesMap.put("test_index", new IndexInfo());
indicesMap.put("test_index_2", new IndexInfo());
PersistentGlobalState state = new PersistentGlobalState(indicesMap);
assertEquals(indicesMap, state.getIndices());
}
use of com.yelp.nrtsearch.server.luceneserver.state.PersistentGlobalState.IndexInfo in project nrtsearch by Yelp.
the class StateUtilsTest method testWriteNewStateFile.
@Test
public void testWriteNewStateFile() throws IOException {
Path expectedStateFilePath = Paths.get(folder.getRoot().getAbsolutePath(), StateUtils.GLOBAL_STATE_FILE);
assertFalse(expectedStateFilePath.toFile().exists());
Map<String, IndexInfo> testIndices = new HashMap<>();
testIndices.put("test_index", new IndexInfo());
testIndices.put("test_index_2", new IndexInfo());
PersistentGlobalState persistentGlobalState = new PersistentGlobalState(testIndices);
StateUtils.writeStateToFile(persistentGlobalState, Paths.get(folder.getRoot().getAbsolutePath()), StateUtils.GLOBAL_STATE_FILE);
assertTrue(expectedStateFilePath.toFile().exists());
PersistentGlobalState readState = StateUtils.readStateFromFile(expectedStateFilePath);
assertEquals(persistentGlobalState, readState);
}
use of com.yelp.nrtsearch.server.luceneserver.state.PersistentGlobalState.IndexInfo in project nrtsearch by Yelp.
the class StateUtilsTest method testReWriteStateFile.
@Test
public void testReWriteStateFile() throws IOException {
Path expectedStateFilePath = Paths.get(folder.getRoot().getAbsolutePath(), StateUtils.GLOBAL_STATE_FILE);
assertFalse(expectedStateFilePath.toFile().exists());
Map<String, IndexInfo> testIndices = new HashMap<>();
testIndices.put("test_index_3", new IndexInfo());
testIndices.put("test_index_4", new IndexInfo());
PersistentGlobalState persistentGlobalState = new PersistentGlobalState(testIndices);
StateUtils.writeStateToFile(persistentGlobalState, Paths.get(folder.getRoot().getAbsolutePath()), StateUtils.GLOBAL_STATE_FILE);
assertTrue(expectedStateFilePath.toFile().exists());
PersistentGlobalState readState = StateUtils.readStateFromFile(expectedStateFilePath);
assertEquals(persistentGlobalState, readState);
testIndices = new HashMap<>();
testIndices.put("test_index_5", new IndexInfo());
testIndices.put("test_index_6", new IndexInfo());
testIndices.put("test_index_7", new IndexInfo());
PersistentGlobalState persistentGlobalState2 = new PersistentGlobalState(testIndices);
StateUtils.writeStateToFile(persistentGlobalState2, Paths.get(folder.getRoot().getAbsolutePath()), StateUtils.GLOBAL_STATE_FILE);
assertTrue(expectedStateFilePath.toFile().exists());
PersistentGlobalState readState2 = StateUtils.readStateFromFile(expectedStateFilePath);
assertEquals(persistentGlobalState2, readState2);
assertNotEquals(readState, readState2);
}
Aggregations