Skip to content

Commit

Permalink
Handle scenario names with spaces when performing migration tests (#7332
Browse files Browse the repository at this point in the history
)
  • Loading branch information
piotrp authored Dec 13, 2024
1 parent 5c6cbb9 commit 364489f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,12 @@ import pl.touk.nussknacker.restmodel.scenariodetails.ScenarioWithDetailsForMigra
import pl.touk.nussknacker.restmodel.validation.ValidationResults.ValidationErrors
import pl.touk.nussknacker.ui.NuDesignerError.XError
import pl.touk.nussknacker.ui.api.description.MigrationApiEndpoints.Dtos.ApiVersion
import pl.touk.nussknacker.ui.migrations.{
MigrateScenarioData,
MigrateScenarioDataV1,
MigrateScenarioDataV2,
MigrationApiAdapterService
}
import pl.touk.nussknacker.ui.migrations.{MigrateScenarioData, MigrateScenarioDataV2, MigrationApiAdapterService}
import pl.touk.nussknacker.ui.security.api.LoggedUser
import pl.touk.nussknacker.ui.util.ScenarioGraphComparator.Difference
import pl.touk.nussknacker.ui.util.{ApiAdapterServiceError, OutOfRangeAdapterRequestError, ScenarioGraphComparator}
import pl.touk.nussknacker.ui.{FatalError, NuDesignerError}

import java.net.URLEncoder
import java.nio.charset.StandardCharsets
import scala.collection.parallel.ExecutionContextTaskSupport
import scala.collection.parallel.immutable.ParVector
import scala.concurrent.duration.{DurationInt, FiniteDuration}
Expand Down Expand Up @@ -156,7 +149,7 @@ class HttpRemoteEnvironment(
)
}

override def close(): Unit = Await.ready(http.shutdownAllConnectionPools(), closeTimeout)
override def close(): Unit = Await.ready(closeAsync(), closeTimeout)

def closeAsync(): Future[Unit] = http.shutdownAllConnectionPools()
}
Expand Down Expand Up @@ -355,7 +348,7 @@ trait StandardRemoteEnvironment extends FailFastCirceSupport with RemoteEnvironm
HttpMethods.GET,
"processesDetails" :: Nil,
Query(
("names", names.map(ns => URLEncoder.encode(ns.value, StandardCharsets.UTF_8)).mkString(",")),
("names", names.map(_.value).mkString(",")),
("isArchived", "false"),
("skipNodeResults", "true"),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class StandardRemoteEnvironmentSpec
request: MessageEntity,
header: Seq[HttpHeader]
): Future[HttpResponse] = {
if (path.toString().startsWith(s"$baseUri/processes/a") && method == HttpMethods.GET) {
if (path == baseUri.withPath(baseUri.path + "/processes/a%20b%20c") && method == HttpMethods.GET) {
Marshal(
ScenarioWithDetailsConversions.fromEntityWithScenarioGraph(
wrapGraphWithScenarioDetailsEntity(name, scenarioGraph),
Expand All @@ -68,7 +68,7 @@ class StandardRemoteEnvironmentSpec
HttpResponse(StatusCodes.OK, entity = entity)
}
} else {
throw new AssertionError(s"Not expected $path")
throw new AssertionError(s"Not expected ${method.value} $path")
}
}
}
Expand All @@ -91,7 +91,7 @@ class StandardRemoteEnvironmentSpec
request: MessageEntity,
headers: Seq[HttpHeader]
): Future[HttpResponse] = {
if (path.toString().startsWith(s"$baseUri/processes/%C5%82%C3%B3d%C5%BA") && method == HttpMethods.GET) {
if (path == baseUri.withPath(baseUri.path + "/processes/%C5%82%C3%B3d%C5%BA") && method == HttpMethods.GET) {
Marshal(
ScenarioWithDetailsConversions.fromEntityWithScenarioGraph(
wrapGraphWithScenarioDetailsEntity(name, scenarioGraph),
Expand Down Expand Up @@ -338,7 +338,7 @@ class StandardRemoteEnvironmentSpec
object GetProcessesDetails {
def unapply(arg: (Uri, HttpMethod)): Option[Set[ProcessName]] = {
val uri = arg._1
if (uri.toString().startsWith(s"$baseUri/processesDetails") && uri
if (uri.withQuery(Uri.Query.Empty) == baseUri.withPath(baseUri.path + "/processesDetails") && uri
.query()
.get("isArchived")
.contains("false") && arg._2 == HttpMethods.GET) {
Expand Down
1 change: 1 addition & 0 deletions docs/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
* Improved scenario state management to include information about current and deployed versions and allow more customization
* [#7184](https://github.com/TouK/nussknacker/pull/7184) Improve Nu Designer API notifications endpoint, to include events related to currently displayed scenario
* [#7323](https://github.com/TouK/nussknacker/pull/7323) Improve Periodic DeploymentManager db queries
* [#7332](https://github.com/TouK/nussknacker/pull/7332) Handle scenario names with spaces when performing migration tests, they were ignored

## 1.18

Expand Down

0 comments on commit 364489f

Please sign in to comment.