mirror of
https://github.com/google/nomulus
synced 2026-09-06 16:17:13 +00:00
This includes two changes: 1. Creating a base string-type adapter for use parsing to/from JSON classes that are represented as simple strings 2. Changing the object-provider methods so that the POST bodies should contain precisely the expected object(s) and nothing else. This way, it's easier for the frontend and backend to agree that, for instance, one POST endpoint might accept exactly a Registrar object, or a list of Contact objects. Co-Authored-By: gbrodman <gbrodman@google.com>
This commit is contained in:
@@ -17,6 +17,7 @@ package google.registry.model.tld;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.Truth.assertWithMessage;
|
||||
import static com.google.common.truth.Truth8.assertThat;
|
||||
import static google.registry.model.EntityYamlUtils.createObjectMapper;
|
||||
import static google.registry.model.ImmutableObjectSubject.assertAboutImmutableObjects;
|
||||
import static google.registry.model.domain.token.AllocationToken.TokenType.DEFAULT_PROMO;
|
||||
import static google.registry.model.domain.token.AllocationToken.TokenType.SINGLE_USE;
|
||||
@@ -24,7 +25,6 @@ import static google.registry.model.tld.Tld.TldState.GENERAL_AVAILABILITY;
|
||||
import static google.registry.model.tld.Tld.TldState.PREDELEGATION;
|
||||
import static google.registry.model.tld.Tld.TldState.QUIET_PERIOD;
|
||||
import static google.registry.model.tld.Tld.TldState.START_DATE_SUNRISE;
|
||||
import static google.registry.model.tld.TldYamlUtils.getObjectMapper;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.testing.DatabaseHelper.createTld;
|
||||
import static google.registry.testing.DatabaseHelper.newTld;
|
||||
@@ -129,7 +129,7 @@ public final class TldTest extends EntityTestCase {
|
||||
.setIdnTables(ImmutableSet.of(IdnTableEnum.JA, IdnTableEnum.EXTENDED_LATIN))
|
||||
.build();
|
||||
|
||||
ObjectMapper mapper = getObjectMapper();
|
||||
ObjectMapper mapper = createObjectMapper();
|
||||
String yaml = mapper.writeValueAsString(existingTld);
|
||||
assertThat(yaml).isEqualTo(loadFile(getClass(), "tld.yaml"));
|
||||
}
|
||||
@@ -162,7 +162,7 @@ public final class TldTest extends EntityTestCase {
|
||||
.setIdnTables(ImmutableSet.of(IdnTableEnum.JA, IdnTableEnum.EXTENDED_LATIN))
|
||||
.build();
|
||||
|
||||
ObjectMapper mapper = getObjectMapper();
|
||||
ObjectMapper mapper = createObjectMapper();
|
||||
Tld constructedTld =
|
||||
mapper.readValue(readResourceBytes(getClass(), "tld.yaml").openBufferedStream(), Tld.class);
|
||||
compareTlds(existingTld, constructedTld);
|
||||
@@ -171,7 +171,7 @@ public final class TldTest extends EntityTestCase {
|
||||
@Test
|
||||
void testSuccess_tldYamlRoundtrip() throws Exception {
|
||||
Tld testTld = createTld("test");
|
||||
ObjectMapper mapper = getObjectMapper();
|
||||
ObjectMapper mapper = createObjectMapper();
|
||||
String yaml = mapper.writeValueAsString(testTld);
|
||||
Tld constructedTld = mapper.readValue(yaml, Tld.class);
|
||||
compareTlds(testTld, constructedTld);
|
||||
|
||||
@@ -20,11 +20,18 @@ import static google.registry.testing.TestDataHelper.loadFile;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import com.beust.jcommander.ParameterException;
|
||||
import google.registry.model.EntityYamlUtils;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Unit tests for {@link GetTldCommand}. */
|
||||
class GetTldCommandTest extends CommandTestCase<GetTldCommand> {
|
||||
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
command.objectMapper = EntityYamlUtils.createObjectMapper();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess() throws Exception {
|
||||
createTld("xn--q9jyb4c");
|
||||
|
||||
Reference in New Issue
Block a user