用gremlin测试和模拟ScalaGraph
我有一个服务类,我正在尝试进行单元测试。服务类别如下-:用gremlin测试和模拟ScalaGraph,gremlin,scalatest,datastax-enterprise-graph,dse-graph-frames,gremlin-scala,Gremlin,Scalatest,Datastax Enterprise Graph,Dse Graph Frames,Gremlin Scala,我有一个服务类,我正在尝试进行单元测试。服务类别如下-: class BtoService @Inject()(db: GrDbConnection, businessService: BusinessService, vertexIdGenerator: VertexIdGenerator) { def updateBto(id: String, updateBTOReq: Updat
class BtoService @Inject()(db: GrDbConnection,
businessService: BusinessService,
vertexIdGenerator: VertexIdGenerator) {
def updateBto(id: String, updateBTOReq: UpdateBTORequest) = {
implicit val g = db.g
val btoVertex = g
.V(
vertexIdGenerator.vertexId(VertexLabels.BTO, id, PropertyLabels.BTO_ID))
.headOption() match {
case Some(value) => value
case None => throw BtoDoesNotExistException(s"BTO $id Does not exists")
}
因此,在测试这个类时,我创建了一个注入服务的模拟(BusinessService,GrDbConnection)——:
GrDbConnection.scala具有定义的db.g-:
val g: ScalaGraph = EmptyGraph
.instance()
.asScala
.configure(_.withRemote(connection))
此处连接具有连接到实际数据库所需的详细信息
因为我可以使用Mockito.when().thenReturn()返回空的scala图,所以我不希望在测试类中使用.configure()选项
我面临的真正问题是,我无法将顶点添加到测试图中,我需要添加一个btoModel作为该图的顶点,因为在服务类中:
val btoVertex = g.V(vertex......()).headOption() - returns a GremlinScala.Aux[scala.vertex, Hnil]
我该怎么做呢?
请致电-nilay0016@gmail.com更多信息
val btoVertex = g.V(vertex......()).headOption() - returns a GremlinScala.Aux[scala.vertex, Hnil]