Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/redis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
用gremlin测试和模拟ScalaGraph_Gremlin_Scalatest_Datastax Enterprise Graph_Dse Graph Frames_Gremlin Scala - Fatal编程技术网

用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]