-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
api for getting a list of customer name matches
- Loading branch information
Showing
5 changed files
with
186 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 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 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
139 changes: 139 additions & 0 deletions
139
src/test/java/com/redhat/labs/omp/resources/CustomerSuggestionTest.java
This file contains 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,139 @@ | ||
package com.redhat.labs.omp.resources; | ||
|
||
import static io.restassured.RestAssured.given; | ||
import static org.hamcrest.CoreMatchers.containsString; | ||
|
||
import java.util.HashMap; | ||
|
||
import javax.inject.Inject; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import com.redhat.labs.omp.model.Engagement; | ||
import com.redhat.labs.omp.service.EngagementService; | ||
import com.redhat.labs.utils.EmbeddedMongoTest; | ||
import com.redhat.labs.utils.TokenUtils; | ||
|
||
import io.quarkus.test.junit.QuarkusTest; | ||
|
||
@EmbeddedMongoTest | ||
@QuarkusTest | ||
class CustomerSuggestionTest { | ||
private static final String ANSWER = "Red Hat"; | ||
private static final String SUGGESTION_URL = "/engagements/customers/suggest"; | ||
|
||
@Inject | ||
EngagementService engagementService; | ||
|
||
String token; | ||
|
||
@BeforeEach | ||
void setUp() throws Exception { | ||
HashMap<String, Long> timeClaims = new HashMap<>(); | ||
token = TokenUtils.generateTokenString("/JwtClaimsWriter.json", timeClaims); | ||
|
||
Engagement engagement = new EngagementResourceTest().mockEngagement(); | ||
engagement.setCustomerName(ANSWER); | ||
engagementService.create(engagement); | ||
} | ||
|
||
@Test void testSuggestionsExactSuccess() throws Exception { | ||
|
||
given() | ||
.when() | ||
.auth().oauth2(token).queryParam("suggest", ANSWER).get(SUGGESTION_URL) | ||
.then() | ||
.statusCode(200).body(containsString(ANSWER)); | ||
} | ||
|
||
@Test void testSuggestionsNoSuggestionFail() throws Exception { | ||
|
||
given() | ||
.when() | ||
.auth().oauth2(token) | ||
.then() | ||
.statusCode(400); | ||
} | ||
|
||
@Test void testSuggestionsStartLowerSuccess() throws Exception { | ||
|
||
given() | ||
.when() | ||
.auth().oauth2(token).queryParam("suggest", "red").get(SUGGESTION_URL) | ||
.then() | ||
.statusCode(200).body(containsString(ANSWER)); | ||
} | ||
|
||
@Test void testSuggestionsStartUpperSuccess() throws Exception { | ||
|
||
given() | ||
.when() | ||
.auth().oauth2(token).queryParam("suggest", "Red").get(SUGGESTION_URL) | ||
.then() | ||
.statusCode(200).body(containsString(ANSWER)); | ||
} | ||
|
||
@Test void testSuggestionStartLowerThanUpperSuccess() throws Exception { | ||
|
||
given() | ||
.when() | ||
.auth().oauth2(token).queryParam("suggest", "rED").get(SUGGESTION_URL) | ||
.then() | ||
.statusCode(200).body(containsString(ANSWER)); | ||
} | ||
|
||
@Test void testSuggestionsEndLowerSuccess() throws Exception { | ||
|
||
given() | ||
.when() | ||
.auth().oauth2(token).queryParam("suggest", "hat").get(SUGGESTION_URL) | ||
.then() | ||
.statusCode(200).body(containsString(ANSWER)); | ||
} | ||
|
||
@Test void testSuggestionsEndUpperSuccess() throws Exception { | ||
|
||
given() | ||
.when() | ||
.auth().oauth2(token).queryParam("suggest", "haT").get(SUGGESTION_URL) | ||
.then() | ||
.statusCode(200).body(containsString(ANSWER)); | ||
} | ||
|
||
@Test void testSuggestionEndLowerThanUpperSuccess() throws Exception { | ||
|
||
given() | ||
.when() | ||
.auth().oauth2(token).queryParam("suggest", "hAT").get(SUGGESTION_URL) | ||
.then() | ||
.statusCode(200).body(containsString(ANSWER)); | ||
} | ||
|
||
@Test void testSuggestionsMidLowerSuccess() throws Exception { | ||
|
||
given() | ||
.when() | ||
.auth().oauth2(token).queryParam("suggest", "ed").get(SUGGESTION_URL) | ||
.then() | ||
.statusCode(200).body(containsString(ANSWER)); | ||
} | ||
|
||
@Test void testSuggestionsMidUpperSuccess() throws Exception { | ||
|
||
given() | ||
.when() | ||
.auth().oauth2(token).queryParam("suggest", "ED").get(SUGGESTION_URL) | ||
.then() | ||
.statusCode(200).body(containsString(ANSWER)); | ||
} | ||
|
||
@Test void testSuggestionMidLowerThanUpperSuccess() throws Exception { | ||
|
||
given() | ||
.when() | ||
.auth().oauth2(token).queryParam("suggest", "eD").get(SUGGESTION_URL) | ||
.then() | ||
.statusCode(200).body(containsString(ANSWER)); | ||
} | ||
} |
This file contains 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