Skip to content

Commit

Permalink
chore: remove duplicated test
Browse files Browse the repository at this point in the history
  • Loading branch information
himanshusinghs committed Nov 14, 2024
1 parent fc6ec99 commit 7b3eb30
Showing 1 changed file with 1 addition and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -336,49 +336,7 @@ public final class Repository {
assertEquals(Name.EQ, eq.component<Named>()!!.name)
assertEquals(
"_id",
(eq.component<HasFieldReference<Unit?>>()!!.reference as HasFieldReference.Known).fieldName
)
assertEquals(
BsonAnyOf(BsonObjectId, BsonNull),
(eq.component<HasValueReference<PsiElement>>()!!.reference as HasValueReference.Runtime).type,
)
}

@ParsingTest(
fileName = "Repository.java",
value = """
import com.mongodb.client.MongoCollection;
import com.mongodb.client.model.Filters;
import org.bson.Document;
import org.bson.types.ObjectId;
import com.mongodb.client.FindIterable;
public final class Repository {
private final MongoCollection<Document> collection;
public Repository(MongoCollection<Document> collection) {
this.collection = collection;
}
public Document findBookById(ObjectId id) {
return this.collection.find(Filters.eq("_id", id)).first();
}
}
""",
)
fun `can parse a basic Filters query for FIND_ONE command`(psiFile: PsiFile) {
val query = psiFile.getQueryAtMethod("Repository", "findBookById")
val parsedQuery = JavaDriverDialect.parser.parse(query)

val command = parsedQuery.component<IsCommand>()
val hasFilter = parsedQuery.component<HasFilter<Unit?>>()!!

val eq = hasFilter.children[0]
assertEquals(IsCommand.CommandType.FIND_ONE, command?.type)
assertEquals(Name.EQ, eq.component<Named>()!!.name)
assertEquals(
"_id",
(eq.component<HasFieldReference<Unit?>>()!!.reference as HasFieldReference.Known).fieldName
(eq.component<HasFieldReference<Unit?>>()!!.reference as HasFieldReference.FromSchema).fieldName
)
assertEquals(
BsonAnyOf(BsonObjectId, BsonNull),
Expand Down

0 comments on commit 7b3eb30

Please sign in to comment.