Skip to content

Commit

Permalink
HSEARCH-3920 Clarify that document references in tests expect a type …
Browse files Browse the repository at this point in the history
…name, not an index name
  • Loading branch information
yrodiere committed May 19, 2020
1 parent 103bac6 commit a40f4a5
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
Expand Up @@ -33,8 +33,8 @@ public final class NormalizationUtils {
private NormalizationUtils() {
}

public static DocumentReference reference(String indexName, String id) {
return new NormalizedDocumentReference( indexName, id );
public static DocumentReference reference(String typeName, String id) {
return new NormalizedDocumentReference( typeName, id );
}

// The casts will work fine as long as we don't reference subclasses of the normalized classes in our tests
Expand Down
Expand Up @@ -21,8 +21,8 @@ public static DocumentReference[] of(Consumer<Builder> contributor) {
return builder.build();
}

public static DocumentReference[] of(String indexName, String firstId, String... otherIds) {
return of( b -> b.doc( indexName, firstId, otherIds ) );
public static DocumentReference[] of(String typeName, String firstId, String... otherIds) {
return of( b -> b.doc( typeName, firstId, otherIds ) );
}

private NormalizedDocRefHit() {
Expand All @@ -35,10 +35,10 @@ public static class Builder {
private Builder() {
}

public Builder doc(String indexName, String firstId, String... otherIds) {
expectedHits.add( NormalizationUtils.reference( indexName, firstId ) );
public Builder doc(String typeName, String firstId, String... otherIds) {
expectedHits.add( NormalizationUtils.reference( typeName, firstId ) );
for ( String id : otherIds ) {
expectedHits.add( NormalizationUtils.reference( indexName, id ) );
expectedHits.add( NormalizationUtils.reference( typeName, id ) );
}
return this;
}
Expand Down
Expand Up @@ -28,11 +28,11 @@ public SearchHitAssert<H> as(String description) {
return this;
}

public void isDocRefHit(String indexName, String id, String... orIds) {
public void isDocRefHit(String typeName, String id, String... orIds) {
Set<DocumentReference> references = new HashSet<>();
references.add( NormalizationUtils.reference( indexName, id ) );
references.add( NormalizationUtils.reference( typeName, id ) );
for ( String orId : orIds ) {
references.add( NormalizationUtils.reference( indexName, orId ) );
references.add( NormalizationUtils.reference( typeName, orId ) );
}

DocumentReference actualReference = NormalizationUtils.normalize( (DocumentReference) actual );
Expand Down
Expand Up @@ -93,15 +93,15 @@ public final SearchHitsAssert<H> hasHitsAnyOrder(Collection<H> hits) {
return hasHitsAnyOrder( (H[]) hits.toArray() );
}

public SearchHitsAssert<H> hasDocRefHitsExactOrder(String indexName, String firstId, String... otherIds) {
public SearchHitsAssert<H> hasDocRefHitsExactOrder(String typeName, String firstId, String... otherIds) {
return hasDocRefHitsExactOrder( ctx -> {
ctx.doc( indexName, firstId, otherIds );
ctx.doc( typeName, firstId, otherIds );
} );
}

public SearchHitsAssert<H> hasDocRefHitsAnyOrder(String indexName, String firstId, String... otherIds) {
public SearchHitsAssert<H> hasDocRefHitsAnyOrder(String typeName, String firstId, String... otherIds) {
return hasDocRefHitsAnyOrder( ctx -> {
ctx.doc( indexName, firstId, otherIds );
ctx.doc( typeName, firstId, otherIds );
} );
}

Expand Down
Expand Up @@ -94,13 +94,13 @@ public final SearchResultAssert<H> hasHitsAnyOrder(Collection<H> hits) {
return this;
}

public SearchResultAssert<H> hasDocRefHitsExactOrder(String indexName, String firstId, String... otherIds) {
hits().hasDocRefHitsExactOrder( indexName, firstId, otherIds );
public SearchResultAssert<H> hasDocRefHitsExactOrder(String typeName, String firstId, String... otherIds) {
hits().hasDocRefHitsExactOrder( typeName, firstId, otherIds );
return this;
}

public SearchResultAssert<H> hasDocRefHitsAnyOrder(String indexName, String firstId, String... otherIds) {
hits().hasDocRefHitsAnyOrder( indexName, firstId, otherIds );
public SearchResultAssert<H> hasDocRefHitsAnyOrder(String typeName, String firstId, String... otherIds) {
hits().hasDocRefHitsAnyOrder( typeName, firstId, otherIds );
return this;
}

Expand Down

0 comments on commit a40f4a5

Please sign in to comment.