-
Notifications
You must be signed in to change notification settings - Fork 227
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Resolves #2784 * Cleaned up imports
- Loading branch information
Showing
3 changed files
with
122 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
61 changes: 61 additions & 0 deletions
61
...ring/elide-spring-boot-autoconfigure/src/test/java/example/tests/Update200StatusTest.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,61 @@ | ||
/* | ||
* Copyright 2022, Yahoo Inc. | ||
* Licensed under the Apache License, Version 2.0 | ||
* See LICENSE file in project root for terms. | ||
*/ | ||
package example.tests; | ||
|
||
import static io.restassured.RestAssured.given; | ||
|
||
import com.yahoo.elide.core.exceptions.HttpStatus; | ||
import com.yahoo.elide.spring.controllers.JsonApiController; | ||
import com.yahoo.elide.test.jsonapi.JsonApiDSL; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.context.annotation.Import; | ||
import org.springframework.test.context.jdbc.Sql; | ||
import org.springframework.test.context.jdbc.SqlMergeMode; | ||
|
||
/** | ||
* Verifies 200 Status for patch Requests. | ||
*/ | ||
@Import(Update200StatusTestSetup.class) | ||
@SqlMergeMode(SqlMergeMode.MergeMode.MERGE) | ||
@Sql( | ||
executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, | ||
scripts = "classpath:db/test_init.sql", | ||
statements = "INSERT INTO ArtifactGroup (name, commonName, description, deprecated) VALUES\n" | ||
+ "\t\t('com.example.repository','Example Repository','The code for this project', false);" | ||
) | ||
public class Update200StatusTest extends IntegrationTest { | ||
private String baseUrl; | ||
|
||
@BeforeAll | ||
@Override | ||
public void setUp() { | ||
super.setUp(); | ||
baseUrl = "https://elide.io/json/"; | ||
} | ||
|
||
@Test | ||
public void jsonApiPatchTest() { | ||
given() | ||
.contentType(JsonApiController.JSON_API_CONTENT_TYPE) | ||
.body( | ||
JsonApiDSL.datum( | ||
JsonApiDSL.resource( | ||
JsonApiDSL.type("group"), | ||
JsonApiDSL.id("com.example.repository"), | ||
JsonApiDSL.attributes( | ||
JsonApiDSL.attr("commonName", "Changed It.") | ||
) | ||
) | ||
) | ||
) | ||
.when() | ||
.patch("/json/group/com.example.repository") | ||
.then() | ||
.contentType(JsonApiController.JSON_API_CONTENT_TYPE) | ||
.statusCode(HttpStatus.SC_OK); | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
...elide-spring-boot-autoconfigure/src/test/java/example/tests/Update200StatusTestSetup.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,56 @@ | ||
/* | ||
* Copyright 2022, Yahoo Inc. | ||
* Licensed under the Apache License, Version 2.0 | ||
* See LICENSE file in project root for terms. | ||
*/ | ||
package example.tests; | ||
|
||
import com.yahoo.elide.Elide; | ||
import com.yahoo.elide.ElideSettingsBuilder; | ||
import com.yahoo.elide.RefreshableElide; | ||
import com.yahoo.elide.core.TransactionRegistry; | ||
import com.yahoo.elide.core.audit.Slf4jLogger; | ||
import com.yahoo.elide.core.datastore.DataStore; | ||
import com.yahoo.elide.core.dictionary.EntityDictionary; | ||
import com.yahoo.elide.core.exceptions.ErrorMapper; | ||
import com.yahoo.elide.core.filter.dialect.RSQLFilterDialect; | ||
import com.yahoo.elide.jsonapi.JsonApiMapper; | ||
import com.yahoo.elide.spring.config.ElideConfigProperties; | ||
import com.yahoo.elide.utils.HeaderUtils; | ||
import org.springframework.boot.test.context.TestConfiguration; | ||
import org.springframework.context.annotation.Bean; | ||
|
||
import java.util.TimeZone; | ||
|
||
@TestConfiguration | ||
public class Update200StatusTestSetup { | ||
@Bean | ||
public RefreshableElide getRefreshableElide(EntityDictionary dictionary, | ||
DataStore dataStore, | ||
HeaderUtils.HeaderProcessor headerProcessor, | ||
TransactionRegistry transactionRegistry, | ||
ElideConfigProperties settings, | ||
JsonApiMapper mapper, | ||
ErrorMapper errorMapper) { | ||
|
||
ElideSettingsBuilder builder = new ElideSettingsBuilder(dataStore) | ||
.withEntityDictionary(dictionary) | ||
.withErrorMapper(errorMapper) | ||
.withJsonApiMapper(mapper) | ||
.withDefaultMaxPageSize(settings.getMaxPageSize()) | ||
.withDefaultPageSize(settings.getPageSize()) | ||
.withJoinFilterDialect(RSQLFilterDialect.builder().dictionary(dictionary).build()) | ||
.withSubqueryFilterDialect(RSQLFilterDialect.builder().dictionary(dictionary).build()) | ||
.withAuditLogger(new Slf4jLogger()) | ||
.withBaseUrl(settings.getBaseUrl()) | ||
.withISO8601Dates("yyyy-MM-dd'T'HH:mm'Z'", TimeZone.getTimeZone("UTC")) | ||
.withJsonApiPath(settings.getJsonApi().getPath()) | ||
.withHeaderProcessor(headerProcessor) | ||
.withGraphQLApiPath(settings.getGraphql().getPath()) | ||
.withUpdate200Status(); | ||
|
||
Elide elide = new Elide(builder.build(), transactionRegistry, dictionary.getScanner(), true); | ||
|
||
return new RefreshableElide(elide); | ||
} | ||
} |