Skip to content

Commit

Permalink
HSEARCH-3836 Test passing routing keys to PojoScopeWorkspace.purge() …
Browse files Browse the repository at this point in the history
…and SearchWorkspace.purge()
  • Loading branch information
yrodiere committed Feb 21, 2020
1 parent 8022a6f commit be05f5c
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 3 deletions.
Expand Up @@ -13,7 +13,7 @@
import org.hibernate.search.util.impl.test.annotation.TestForIssue;

@TestForIssue(jiraKey = "HSEARCH-3049")
public class SearchWorkspacePurgeIT extends AbstractSearchWorkspaceSimpleOperationIT {
public class SearchWorkspacePurgeBaseIT extends AbstractSearchWorkspaceSimpleOperationIT {
@Override
protected void expectWork(BackendMock backendMock, String indexName, CompletableFuture<?> future) {
backendMock.expectIndexScaleWorks( indexName )
Expand Down
@@ -0,0 +1,37 @@
/*
* Hibernate Search, full-text search for your domain model
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.search.integrationtest.mapper.orm.workspace;

import java.util.Set;
import java.util.concurrent.CompletableFuture;

import org.hibernate.search.mapper.orm.work.SearchWorkspace;
import org.hibernate.search.util.common.impl.CollectionHelper;
import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock;
import org.hibernate.search.util.impl.test.annotation.TestForIssue;

@TestForIssue(jiraKey = "HSEARCH-3049")
public class SearchWorkspacePurgeRoutingKeyIT extends AbstractSearchWorkspaceSimpleOperationIT {

private final Set<String> ROUTING_KEYS = CollectionHelper.asLinkedHashSet( "key1", "key2" );

@Override
protected void expectWork(BackendMock backendMock, String indexName, CompletableFuture<?> future) {
backendMock.expectIndexScaleWorks( indexName )
.purge( ROUTING_KEYS, future );
}

@Override
protected void executeSync(SearchWorkspace workspace) {
workspace.purge( ROUTING_KEYS );
}

@Override
protected CompletableFuture<?> executeAsync(SearchWorkspace workspace) {
return workspace.purgeAsync( ROUTING_KEYS );
}
}
Expand Up @@ -43,7 +43,7 @@ public CompletableFuture<?> purgeAsync() {

@Override
public void purge(Set<String> routingKeys) {
Futures.unwrappedExceptionJoin( purgeAsync() );
Futures.unwrappedExceptionJoin( purgeAsync( routingKeys ) );
}

@Override
Expand Down
Expand Up @@ -355,6 +355,14 @@ public IndexScaleWorkCallListContext purge(CompletableFuture<?> future) {
return indexScaleWork( StubIndexScaleWork.Type.PURGE, future );
}

public IndexScaleWorkCallListContext purge(Set<String> routingKeys) {
return indexScaleWork( StubIndexScaleWork.Type.PURGE, routingKeys );
}

public IndexScaleWorkCallListContext purge(Set<String> routingKeys, CompletableFuture<?> future) {
return indexScaleWork( StubIndexScaleWork.Type.PURGE, routingKeys, future );
}

public IndexScaleWorkCallListContext flush() {
return indexScaleWork( StubIndexScaleWork.Type.FLUSH );
}
Expand All @@ -372,12 +380,22 @@ public IndexScaleWorkCallListContext refresh(CompletableFuture<?> future) {
}

public IndexScaleWorkCallListContext indexScaleWork(StubIndexScaleWork.Type type) {
return indexScaleWork( type, CompletableFuture.completedFuture( null ) );
return indexScaleWork( type, Collections.emptySet() );
}

public IndexScaleWorkCallListContext indexScaleWork(StubIndexScaleWork.Type type, CompletableFuture<?> future) {
return indexScaleWork( type, Collections.emptySet(), future );
}

public IndexScaleWorkCallListContext indexScaleWork(StubIndexScaleWork.Type type, Set<String> routingKeys) {
return indexScaleWork( type, routingKeys, CompletableFuture.completedFuture( null ) );
}

public IndexScaleWorkCallListContext indexScaleWork(StubIndexScaleWork.Type type, Set<String> routingKeys,
CompletableFuture<?> future) {
StubIndexScaleWork work = StubIndexScaleWork.builder( type )
.tenantIdentifier( tenantIdentifier )
.routingKeys( routingKeys )
.build();
expectationConsumer.accept( new IndexScaleWorkCalls( indexNames, work, future ) );
return this;
Expand Down

0 comments on commit be05f5c

Please sign in to comment.