Skip to content

Commit

Permalink
Get rid of null for rest result
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincent Hou committed Oct 19, 2017
1 parent 8586628 commit 8499491
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions tests/src/test/scala/common/rest/WskRest.scala
Expand Up @@ -116,7 +116,6 @@ trait ListOrGetFromCollectionRest extends BaseListOrGetFromCollection {
nameSort: Option[Boolean] = None,
expectedExitCode: Int = OK.intValue)(implicit wp: WskProps): RestResult = {
val (ns, name) = getNamespaceActionName(resolve(namespace))

val pathToList = s"$basePath/namespaces/$ns/$noun"
val entPath =
if (name != "") Path(s"$pathToList/$name/")
Expand Down Expand Up @@ -275,8 +274,10 @@ class WskRestAction
kindType = "php:default"
code = FileUtils.readFileToString(new File(artifactFile))
}
case _ =>
}
}
case None =>
}

kindType = docker map { d =>
Expand All @@ -293,7 +294,7 @@ class WskRestAction
val actionPath = Path(s"$basePath/namespaces/$namespace/$noun/$actName")
val resp = requestEntity(GET, actionPath)
if (resp == None)
return new RestResult(NotFound, null)
return new RestResult(NotFound)
else {
val result = new RestResult(resp.status, getRespData(resp))
params = JsArray(result.getFieldListJsObject("parameters"))
Expand Down Expand Up @@ -713,7 +714,7 @@ class WskRestActivation extends RunWskRestCmd with HasActivationRest with WaitFo
new RestResult(resp.status, getRespData(resp))
}
case None => {
new RestResult(NotFound, null)
new RestResult(NotFound)
}
}
validateStatusCode(expectedExitCode, r.statusCode.intValue)
Expand Down Expand Up @@ -748,7 +749,7 @@ class WskRestActivation extends RunWskRestCmd with HasActivationRest with WaitFo

def waitForActivationConsole(totalWait: Duration = 30 seconds, sinceTime: Instant)(
implicit wp: WskProps): RestResult = {
var result = new RestResult(NotFound, null)
var result = new RestResult(NotFound)
Thread.sleep(totalWait.toMillis)
listActivation(since = Some(sinceTime))(wp)
}
Expand All @@ -762,7 +763,7 @@ class WskRestActivation extends RunWskRestCmd with HasActivationRest with WaitFo
new RestResult(resp.status, getRespData(resp))
}
case None => {
new RestResult(NotFound, null)
new RestResult(NotFound)
}
}
validateStatusCode(expectedExitCode, r.statusCode.intValue)
Expand All @@ -778,7 +779,7 @@ class WskRestActivation extends RunWskRestCmd with HasActivationRest with WaitFo
new RestResult(resp.status, getRespData(resp))
}
case None => {
new RestResult(NotFound, null)
new RestResult(NotFound)
}
}
validateStatusCode(expectedExitCode, r.statusCode.intValue)
Expand All @@ -803,7 +804,7 @@ class WskRestNamespace extends RunWskRestCmd with BaseNamespace {
implicit wp: WskProps): RestResult = {
val entPath = Path(s"$basePath/namespaces")
val resp = requestEntity(GET, entPath)
val result = if (resp == None) new RestResult(NotFound, null) else new RestResult(resp.status, getRespData(resp))
val result = if (resp == None) new RestResult(NotFound) else new RestResult(resp.status, getRespData(resp))
validateStatusCode(expectedExitCode, result.statusCode.intValue)
result
}
Expand Down Expand Up @@ -994,7 +995,7 @@ class WskRestApi extends RunWskRestCmd with BaseApi {
expectedExitCode = expectedExitCode)(wp)
}
case None => {
new RestResult(NotFound, null)
new RestResult(NotFound)
}
}
r
Expand Down Expand Up @@ -1141,7 +1142,7 @@ class RunWskRestCmd() extends FlatSpec with RunWskCmd with Matchers with ScalaFu
def getExt(filePath: String)(implicit wp: WskProps) = {
val sep = "."
if (filePath.contains(sep)) filePath.substring(filePath.lastIndexOf(sep), filePath.length())
else null
else ""
}

def request(method: HttpMethod,
Expand Down Expand Up @@ -1384,7 +1385,7 @@ object RestResult {
}
}

class RestResult(var statusCode: StatusCode, var respData: String)
class RestResult(var statusCode: StatusCode, var respData: String = "")
extends RunResult(
RestResult.convertStausCodeToExitCode(statusCode),
respData,
Expand Down

0 comments on commit 8499491

Please sign in to comment.