Skip to content
This repository has been archived by the owner on Mar 12, 2020. It is now read-only.

Commit

Permalink
Simplify getElementByRetestId #24
Browse files Browse the repository at this point in the history
  • Loading branch information
tdauth committed Apr 9, 2019
1 parent b09e9b7 commit 78a981f
Showing 1 changed file with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import de.retest.recheck.ui.descriptors.{Element, SutState}
import de.retest.surili.commons.actions._
import org.neo4j.ogm.typeconversion.AttributeConverter

import scala.collection.JavaConverters._
import scala.xml._

/**
Expand Down Expand Up @@ -91,20 +92,17 @@ class ActionConverter(val sutState: Option[SutState]) extends AttributeConverter
}

private def getElementByRetestId(retestId: String, sutState: SutState): Option[Element] = {
val elements = scala.collection.mutable.Set[Element]()
val iterator = sutState.getRootElements.iterator()
val elements = asScalaBuffer(sutState.getRootElements).toBuffer[Element]
val iterator = elements.iterator
var result: Option[Element] = None

while (iterator.hasNext && result.isEmpty) {
val element = iterator.next()
result = if (element.getRetestId == retestId) {
Some(element)
} else { None }

val nestedIterator = element.getContainedElements.iterator()

while (nestedIterator.hasNext) {
elements += nestedIterator.next()
} else {
elements ++= asScalaBuffer(element.getContainedElements)
None
}
}

Expand Down

0 comments on commit 78a981f

Please sign in to comment.