Skip to content

Commit

Permalink
HSEARCH-3759 Rename PushSchemaCall to SchemaDefinitionCall
Browse files Browse the repository at this point in the history
To remove any confusion between schema definition and schema management.
  • Loading branch information
yrodiere committed Mar 6, 2020
1 parent 76926d2 commit a292898
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 23 deletions.
Expand Up @@ -61,7 +61,7 @@ public void twoPhaseBoot() {
HibernateOrmIntegrationBooter booter = createBooter( IndexedEntity.class );
Map<String, Object> booterGeneratedProperties = new LinkedHashMap<>();

// Pre-booting should lead to a schema creation in the backend.
// Pre-booting should lead to a schema definition in the backend.
backendMock.expectSchema( INDEX_NAME, b -> { } );
booter.preBoot( booterGeneratedProperties::put );
backendMock.verifyExpectationsMet();
Expand Down
Expand Up @@ -126,16 +126,16 @@ public BackendMock expectSchema(String indexName, Consumer<StubIndexSchemaNode.B

public BackendMock expectSchema(String indexName, Consumer<StubIndexSchemaNode.Builder> contributor,
Capture<StubIndexSchemaNode> capture) {
CallQueue<PushSchemaCall> callQueue = behaviorMock.getPushSchemaCalls( indexName );
CallQueue<SchemaDefinitionCall> callQueue = behaviorMock.getSchemaDefinitionCalls( indexName );
StubIndexSchemaNode.Builder builder = StubIndexSchemaNode.schema();
contributor.accept( builder );
callQueue.expectOutOfOrder( new PushSchemaCall( indexName, builder.build(), capture ) );
callQueue.expectOutOfOrder( new SchemaDefinitionCall( indexName, builder.build(), capture ) );
return this;
}

public BackendMock expectAnySchema(String indexName) {
CallQueue<PushSchemaCall> callQueue = behaviorMock.getPushSchemaCalls( indexName );
callQueue.expectOutOfOrder( new PushSchemaCall( indexName, null ) );
CallQueue<SchemaDefinitionCall> callQueue = behaviorMock.getSchemaDefinitionCalls( indexName );
callQueue.expectOutOfOrder( new SchemaDefinitionCall( indexName, null ) );
return this;
}

Expand Down
Expand Up @@ -13,25 +13,25 @@

import org.easymock.Capture;

class PushSchemaCall extends Call<PushSchemaCall> {
class SchemaDefinitionCall extends Call<SchemaDefinitionCall> {

private final String indexName;
private final StubIndexSchemaNode schemaNode;
private final Capture<StubIndexSchemaNode> capture;

PushSchemaCall(String indexName, StubIndexSchemaNode schemaNode) {
SchemaDefinitionCall(String indexName, StubIndexSchemaNode schemaNode) {
this.indexName = indexName;
this.schemaNode = schemaNode;
this.capture = null;
}

PushSchemaCall(String indexName, StubIndexSchemaNode schemaNode, Capture<StubIndexSchemaNode> capture) {
SchemaDefinitionCall(String indexName, StubIndexSchemaNode schemaNode, Capture<StubIndexSchemaNode> capture) {
this.indexName = indexName;
this.schemaNode = schemaNode;
this.capture = capture;
}

public CallBehavior<Void> verify(PushSchemaCall actualCall) {
public CallBehavior<Void> verify(SchemaDefinitionCall actualCall) {
if ( schemaNode != null ) {
StubTreeNodeAssert.assertThat( actualCall.schemaNode )
.as( "Schema for index '" + indexName + "' did not match:\n" )
Expand All @@ -48,13 +48,13 @@ public CallBehavior<Void> verify(PushSchemaCall actualCall) {
}

@Override
protected boolean isSimilarTo(PushSchemaCall other) {
protected boolean isSimilarTo(SchemaDefinitionCall other) {
return Objects.equals( indexName, other.indexName );
}

@Override
public String toString() {
return "push schema to index '" + indexName + "'; schema = " + schemaNode;
return "schema definition for index '" + indexName + "'; schema = " + schemaNode;
}

}
Expand Up @@ -42,7 +42,7 @@ class VerifyingStubBackendBehavior extends StubBackendBehavior {

private final List<CallBehavior<Void>> stopBackendBehaviors = new ArrayList<>();

private final Map<String, CallQueue<PushSchemaCall>> pushSchemaCalls = new HashMap<>();
private final Map<String, CallQueue<SchemaDefinitionCall>> schemaDefinitionCalls = new HashMap<>();

private final Map<String, CallQueue<SchemaManagementWorkCall>> schemaManagementWorkCall = new HashMap<>();

Expand Down Expand Up @@ -72,8 +72,8 @@ void setIndexFieldAddBehavior(String indexName, String absoluteFieldPath, CallBe
indexFieldAddBehaviors.put( new IndexFieldKey( indexName, absoluteFieldPath ), behavior );
}

CallQueue<PushSchemaCall> getPushSchemaCalls(String indexName) {
return pushSchemaCalls.computeIfAbsent( indexName, ignored -> new CallQueue<>() );
CallQueue<SchemaDefinitionCall> getSchemaDefinitionCalls(String indexName) {
return schemaDefinitionCalls.computeIfAbsent( indexName, ignored -> new CallQueue<>() );
}

CallQueue<SchemaManagementWorkCall> getSchemaManagementWorkCalls(String indexName) {
Expand All @@ -100,14 +100,14 @@ void resetExpectations() {
createBackendBehaviors.clear();
stopBackendBehaviors.clear();
indexFieldAddBehaviors.clear();
pushSchemaCalls.clear();
schemaDefinitionCalls.clear();
documentWorkCalls.clear();
searchCalls.reset();
}

void verifyExpectationsMet() {
// We don't check anything for the various behaviors (createBackendBehaviors, ...): they are ignored if they are not executed.
pushSchemaCalls.values().forEach( CallQueue::verifyExpectationsMet );
schemaDefinitionCalls.values().forEach( CallQueue::verifyExpectationsMet );
documentWorkCalls.values().forEach( CallQueue::verifyExpectationsMet );
searchCalls.verifyExpectationsMet();
}
Expand Down Expand Up @@ -135,11 +135,11 @@ public void onAddField(String indexName, String absoluteFieldPath) {
}

@Override
public void pushSchema(String indexName, StubIndexSchemaNode rootSchemaNode) {
getPushSchemaCalls( indexName )
public void defineSchema(String indexName, StubIndexSchemaNode rootSchemaNode) {
getSchemaDefinitionCalls( indexName )
.verify(
new PushSchemaCall( indexName, rootSchemaNode ),
PushSchemaCall::verify,
new SchemaDefinitionCall( indexName, rootSchemaNode ),
SchemaDefinitionCall::verify,
noExpectationsBehavior( () -> null )
);
}
Expand Down
Expand Up @@ -43,7 +43,7 @@ public void onAddField(String indexName, String absoluteFieldPath) {
}

@Override
public void pushSchema(String indexName, StubIndexSchemaNode rootSchemaNode) {
public void defineSchema(String indexName, StubIndexSchemaNode rootSchemaNode) {
throw new IllegalStateException( "The stub backend behavior was not set when a schema was pushed for index '"
+ indexName + "': " + rootSchemaNode );
}
Expand Down Expand Up @@ -123,7 +123,7 @@ protected StubBackendBehavior() {

public abstract void onAddField(String indexName, String absoluteFieldPath);

public abstract void pushSchema(String indexName, StubIndexSchemaNode rootSchemaNode);
public abstract void defineSchema(String indexName, StubIndexSchemaNode rootSchemaNode);

public abstract CompletableFuture<?> executeSchemaManagementWork(String indexName, StubSchemaManagementWork work,
ContextualFailureCollector failureCollector);
Expand Down
Expand Up @@ -45,7 +45,7 @@ public class StubIndexManager implements IndexManagerImplementor, IndexManager {
this.name = name;
this.mappedTypeName = mappedTypeName;
this.rootSchemaNode = rootSchemaNode;
backend.getBehavior().pushSchema( name, rootSchemaNode );
backend.getBehavior().defineSchema( name, rootSchemaNode );
}

@Override
Expand Down

0 comments on commit a292898

Please sign in to comment.