This repository was archived by the owner on Jun 8, 2026. It is now read-only.
Repository navigation
resolve twingly/twingly-search-api-java#9 #18
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5ad0b4b
resolve twingly/twingly-search-api-java#9
xSAVIKx d8ef6ba
rewrite betamax test with Spock
xSAVIKx 3d6b08b
Updated betamax tape for invalid key test
xSAVIKx c1f79cc
add betamax-snapshot dependency
xSAVIKx 093baa0
update .gitignore with betamax certificates
xSAVIKx 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
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
48 changes: 48 additions & 0 deletions
48
src/test/groovy/com/twingly/search/client/UrlConnectionClientFunctionSpockTest.groovy
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,48 @@ | ||
| package com.twingly.search.client | ||
|
|
||
| import com.twingly.search.QueryBuilder | ||
| import com.twingly.search.domain.Language | ||
| import com.twingly.search.exception.TwinglySearchServerAPIKeyDoesNotExistException | ||
| import org.junit.Rule | ||
| import software.betamax.Configuration | ||
| import software.betamax.ProxyConfiguration | ||
| import software.betamax.TapeMode | ||
| import software.betamax.junit.Betamax | ||
| import software.betamax.junit.RecorderRule | ||
| import spock.lang.Specification | ||
|
|
||
| class UrlConnectionClientFunctionSpockTest extends Specification { | ||
| private static final String TAPES_STORAGE = "src/test/resources/com/twingly/search/client/tapes"; | ||
|
|
||
| File f = new File(TAPES_STORAGE); | ||
| Configuration configuration = ProxyConfiguration.builder().tapeRoot(f).sslEnabled(true).build(); | ||
| @Rule | ||
| RecorderRule recorder = new RecorderRule(configuration); | ||
|
|
||
| @Betamax(tape = "search for spotify", mode = TapeMode.READ_WRITE) | ||
| def "search for spotify"() { | ||
| given: | ||
| def apiKey = "API_KEY" | ||
| def client = new UrlConnectionClient(apiKey); | ||
| def searchPattern = "spotify page-size:10"; | ||
| def query = QueryBuilder.create(searchPattern).documentLanguage(Language.English).build(); | ||
| when: | ||
| def result = client.makeRequest(query); | ||
| then: | ||
| result != null | ||
| result.getNumberOfMatchesReturned() == 10 | ||
| } | ||
|
|
||
| @Betamax(tape = "search without valid API key", mode = TapeMode.READ_WRITE) | ||
| def "search without valid api key"() { | ||
| given: | ||
| def apiKey = "API_KEY" | ||
| def client = new UrlConnectionClient(apiKey); | ||
| def searchPattern = "some pattern"; | ||
| def query = QueryBuilder.create(searchPattern).build(); | ||
| when: | ||
| client.makeRequest(query); | ||
| then: | ||
| thrown(TwinglySearchServerAPIKeyDoesNotExistException) | ||
| } | ||
| } |
Oops, something went wrong.
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.
What is
betamaxVersionused for? Seems to me that onlybetamaxSnapshotVersionis used.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.
@walro I think it's left in so we can easily switch back when a proper release of betamax has been made
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.
Yeah, I thought it was something like that. I'd like it removed anyway, but we can do it ourselves.
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.
@walro Yeap it was just for simplification of future dependency version change.