-
Notifications
You must be signed in to change notification settings - Fork 5
Retrieve endpoint/15 #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
778090d
Extracting source object from es response
388ddaf
Added elastic actor test
55b14a8
Updated elastic actor test with mock data
045d075
Merge branch 'develop' into RetrieveEndpoint/15
hariharansrc 4743fac
Moved ElasticActorTest to integration test
f0fa33e
Reverting to latest akka http version
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 111 additions & 0 deletions
111
src/it/scala/de/upb/cs/swt/delphi/webapi/ElasticActorTest.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
|
|
||
| // Copyright (C) 2018 The Delphi Team. | ||
| // See the LICENCE file distributed with this work for additional | ||
| // information regarding copyright ownership. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
|
|
||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| package de.upb.cs.swt.delphi.webapi | ||
|
|
||
| import akka.actor.ActorSystem | ||
| import akka.http.scaladsl.Http | ||
| import akka.http.scaladsl.model.{HttpRequest, HttpResponse} | ||
| import akka.http.scaladsl.unmarshalling.Unmarshal | ||
| import akka.stream.ActorMaterializer | ||
| import com.sksamuel.elastic4s.RefreshPolicy | ||
| import com.sksamuel.elastic4s.http.ElasticClient | ||
| import com.sksamuel.elastic4s.http.ElasticDsl._ | ||
| import org.scalatest.{BeforeAndAfterAll, FlatSpec, Matchers} | ||
|
|
||
| import scala.concurrent.duration._ | ||
| import scala.concurrent.{Await, Future} | ||
| import scala.util.{Failure, Success} | ||
|
|
||
| /** | ||
| * @author Hariharan. | ||
| */ | ||
| class ElasticActorTest extends FlatSpec with Matchers with BeforeAndAfterAll { | ||
| implicit val system = ActorSystem() | ||
| implicit val materializer = ActorMaterializer()(system) | ||
| implicit val executionContext = system.dispatcher | ||
| val configuration = new Configuration() | ||
| val client = ElasticClient(configuration.elasticsearchClientUri) | ||
|
|
||
| override def beforeAll(): Unit = { | ||
| client.execute { | ||
| indexInto("delphi" / "project").fields( | ||
| "name" -> "test:elastic-actor-test:1.0" | ||
| ).refresh(RefreshPolicy.IMMEDIATE) | ||
| }.await | ||
| } | ||
|
|
||
|
|
||
| override def afterAll(): Unit = { | ||
| client.execute { | ||
| deleteByQuery("delphi", "project", matchQuery("name", "test:elastic-actor-test:1.0")) | ||
| }.await | ||
| client.close() | ||
| system.terminate() | ||
|
|
||
| } | ||
|
|
||
|
|
||
| "Version no.." should | ||
| "match version from build.sbt" in { | ||
| val res: Future[HttpResponse] = Http().singleRequest(HttpRequest(uri = "http://localhost:8080/version")) | ||
| res.onComplete { | ||
| case Success(ver) => { | ||
| assert(ver.status.isSuccess()); | ||
| val res2Str: Future[String] = Unmarshal(ver.entity).to[String] | ||
| res2Str.onComplete { | ||
| case Success(value) => { | ||
| assert(value.equals(BuildInfo.version)) | ||
| } | ||
| case Failure(e) => { | ||
| assertThrows(e); | ||
| } | ||
| } | ||
| } | ||
| case Failure(e) => { | ||
| assertThrows(e); | ||
| } | ||
| } | ||
| Await.result(res, 2.seconds) | ||
| } | ||
|
|
||
| "Retrive endpoint" should | ||
| "get test:elastic-actor-test:1.0 artifact" in { | ||
| val mavenId = "test:elastic-actor-test:1.0" | ||
| val url = s"http://localhost:8080/retrieve/${mavenId}" | ||
| val res: Future[HttpResponse] = Http().singleRequest(HttpRequest(uri = url)) | ||
| res.onComplete { | ||
| case Success(data) => { | ||
| assert(data.status.isSuccess()) | ||
| val res2Str: Future[String] = Unmarshal(data.entity).to[String] | ||
| res2Str.onComplete { | ||
| case Success(value) => { | ||
| assert(value.contains(mavenId)) | ||
| } | ||
| case Failure(e) => { | ||
| assertThrows(e); | ||
| } | ||
| } | ||
| } | ||
| case Failure(exception) => { | ||
| assertThrows(exception) | ||
| } | ||
| } | ||
| Await.result(res, 2.seconds) | ||
| } | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you remove the usage of
akkaHttpVersionand reverted back to the old (and vulnerable) version ofakka-http?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was a merge conflict. Reverted to the correct http version.