Search in sources :

Example 1 with Address

use of example.Address in project elide by yahoo.

the class PersistentResourceTest method testUpdateNullComplexAttributeSuccess.

@Test
public void testUpdateNullComplexAttributeSuccess() {
    Company company = newCompany("abc");
    company.setAddress(new Address());
    RequestScope goodScope = buildRequestScope(tx, goodUser);
    PersistentResource<Company> parentResource = new PersistentResource<>(company, "1", goodScope);
    final Address address = null;
    boolean updated = parentResource.updateAttribute("address", address);
    assertTrue(updated);
    assertNull(company.getAddress(), "The attribute was updated successfully");
    goodScope.saveOrCreateObjects();
    verify(tx, times(1)).save(company, goodScope);
}
Also used : Company(example.Company) Address(example.Address) PatchRequestScope(com.yahoo.elide.jsonapi.extensions.PatchRequestScope) Test(org.junit.jupiter.api.Test)

Example 2 with Address

use of example.Address in project elide by yahoo.

the class PersistentResourceTest method testUpdateComplexAttributeAllNullFields.

@Test
public void testUpdateComplexAttributeAllNullFields() {
    Company company = newCompany("abc");
    RequestScope goodScope = buildRequestScope(tx, goodUser);
    PersistentResource<Company> parentResource = new PersistentResource<>(company, "1", goodScope);
    final Address address = new Address();
    address.setStreet1(null);
    address.setStreet2(null);
    parentResource.updateAttribute("address", address);
    assertEquals(address, company.getAddress(), "The attribute was updated successfully");
    goodScope.saveOrCreateObjects();
    verify(tx, times(1)).save(company, goodScope);
}
Also used : Company(example.Company) Address(example.Address) PatchRequestScope(com.yahoo.elide.jsonapi.extensions.PatchRequestScope) Test(org.junit.jupiter.api.Test)

Example 3 with Address

use of example.Address in project elide by yahoo.

the class PersistentResourceTest method testUpdateComplexAttributeSuccess.

@Test
public void testUpdateComplexAttributeSuccess() {
    Company company = newCompany("abc");
    RequestScope goodScope = buildRequestScope(tx, goodUser);
    PersistentResource<Company> parentResource = new PersistentResource<>(company, "1", goodScope);
    final Address address = new Address();
    address.setStreet1("street1");
    address.setStreet2("street2");
    parentResource.updateAttribute("address", address);
    assertEquals(address, company.getAddress(), "The attribute was updated successfully");
    goodScope.saveOrCreateObjects();
    verify(tx, times(1)).save(company, goodScope);
}
Also used : Company(example.Company) Address(example.Address) PatchRequestScope(com.yahoo.elide.jsonapi.extensions.PatchRequestScope) Test(org.junit.jupiter.api.Test)

Example 4 with Address

use of example.Address in project elide by yahoo.

the class OperatorTest method complexAttributeTest.

@Test
public void complexAttributeTest() throws Exception {
    author = new Author();
    author.setId(1L);
    Address address1 = new Address();
    address1.setStreet1("Foo");
    author.setHomeAddress(address1);
    fn = Operator.IN.contextualize(constructPath(Author.class, "homeAddress.street1"), Arrays.asList("Foo", "Bar"), requestScope);
    assertTrue(fn.test(author));
    fn = Operator.IN.contextualize(constructPath(Author.class, "homeAddress.street1"), Arrays.asList("Baz"), requestScope);
    assertFalse(fn.test(author));
}
Also used : Address(example.Address) Author(example.Author) Test(org.junit.jupiter.api.Test)

Example 5 with Address

use of example.Address in project elide by yahoo.

the class PersistentResourceTest method testUpdateComplexAttributeAllNullFieldsNested.

@Test
public void testUpdateComplexAttributeAllNullFieldsNested() {
    Company company = newCompany("abc");
    RequestScope goodScope = buildRequestScope(tx, goodUser);
    PersistentResource<Company> parentResource = new PersistentResource<>(company, "1", goodScope);
    final Address address = new Address();
    address.setStreet1(null);
    address.setStreet2(null);
    final GeoLocation geo = new GeoLocation();
    geo.setLatitude("lat");
    geo.setLongitude("long");
    address.setGeo(geo);
    parentResource.updateAttribute("address", address);
    assertEquals(address, company.getAddress(), "The attribute was updated successfully");
    goodScope.saveOrCreateObjects();
    verify(tx, times(1)).save(company, goodScope);
}
Also used : Company(example.Company) Address(example.Address) GeoLocation(example.GeoLocation) PatchRequestScope(com.yahoo.elide.jsonapi.extensions.PatchRequestScope) Test(org.junit.jupiter.api.Test)

Aggregations

Address (example.Address)15 Test (org.junit.jupiter.api.Test)13 Company (example.Company)11 PatchRequestScope (com.yahoo.elide.jsonapi.extensions.PatchRequestScope)10 GeoLocation (example.GeoLocation)6 Author (example.Author)2 DataStoreIterableBuilder (com.yahoo.elide.core.datastore.DataStoreIterableBuilder)1 DataStoreTransaction (com.yahoo.elide.core.datastore.DataStoreTransaction)1 GraphQLTest (com.yahoo.elide.graphql.GraphQLTest)1 IntegrationTest (com.yahoo.elide.initialization.IntegrationTest)1 Book (example.Book)1 Child (example.Child)1 ExceptionThrowingBean (example.ExceptionThrowingBean)1 FunWithPermissions (example.FunWithPermissions)1 Invoice (example.Invoice)1 LineItem (example.LineItem)1 Parent (example.Parent)1 User (example.User)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1