Search in sources :

Example 1 with User

use of example.User in project elide by yahoo.

the class ResourceIT method setup.

@BeforeEach
public void setup() throws IOException {
    dataStore.populateEntityDictionary(EntityDictionary.builder().build());
    DataStoreTransaction tx = dataStore.beginTransaction();
    final Company company = new Company();
    company.setId("abc");
    company.setDescription("ABC");
    Address address = new Address();
    address.setStreet1("foo");
    address.setProperties(Map.of("boo", "baz"));
    company.setAddress(address);
    tx.createObject(company, null);
    // id 1
    Parent parent = new Parent();
    // id 1
    Child child = new Child();
    parent.setChildren(Sets.newHashSet(child));
    parent.setSpouses(Sets.newHashSet());
    child.setParents(Sets.newHashSet(parent));
    tx.createObject(parent, null);
    tx.createObject(child, null);
    // Single tests
    // id 2
    Parent p1 = new Parent();
    p1.setFirstName("John");
    p1.setSpouses(Sets.newHashSet());
    // id 2
    Child c1 = new Child();
    c1.setName("Child-ID2");
    c1.setParents(Sets.newHashSet(p1));
    // id 3
    Child c2 = new Child();
    c2.setName("Child-ID3");
    c2.setParents(Sets.newHashSet(p1));
    Set<Child> friendSet = new HashSet<>();
    friendSet.add(c2);
    c1.setFriends(friendSet);
    Set<Child> childrenSet1 = new HashSet<>();
    childrenSet1.add(c1);
    childrenSet1.add(c2);
    p1.setChildren(childrenSet1);
    // List tests
    // id 3
    Parent p2 = new Parent();
    // id 4
    Parent p3 = new Parent();
    // id 4
    Child c3 = new Child();
    c3.setParents(Sets.newHashSet(p2));
    // id 5
    Child c4 = new Child();
    c4.setParents(Sets.newHashSet(p2));
    Set<Child> childrenSet2 = new HashSet<>();
    childrenSet2.add(c3);
    childrenSet2.add(c4);
    p2.setChildren(childrenSet2);
    p2.setFirstName("Link");
    p3.setFirstName("Unknown");
    p2.setSpouses(Sets.newHashSet());
    p3.setSpouses(Sets.newHashSet(p2));
    p3.setChildren(Sets.newHashSet());
    tx.createObject(c1, null);
    tx.createObject(c2, null);
    tx.createObject(c3, null);
    tx.createObject(c4, null);
    tx.createObject(p1, null);
    tx.createObject(p2, null);
    tx.createObject(p3, null);
    Book bookWithPercentage = new Book();
    bookWithPercentage.setTitle("titlewith%percentage");
    Book bookWithoutPercentage = new Book();
    bookWithoutPercentage.setTitle("titlewithoutpercentage");
    tx.createObject(bookWithPercentage, null);
    tx.createObject(bookWithoutPercentage, null);
    FunWithPermissions fun = new FunWithPermissions();
    tx.createObject(fun, null);
    // ID 1
    User user = new User();
    user.setPassword("god");
    tx.createObject(user, null);
    Invoice invoice = new Invoice();
    invoice.setId(1);
    LineItem item = new LineItem();
    invoice.setItems(Sets.newHashSet(item));
    item.setInvoice(invoice);
    tx.createObject(invoice, null);
    tx.createObject(item, null);
    ExceptionThrowingBean etb = new ExceptionThrowingBean();
    etb.setId(1L);
    tx.createObject(etb, null);
    tx.commit(null);
    tx.close();
}
Also used : Company(example.Company) User(example.User) Invoice(example.Invoice) Address(example.Address) Parent(example.Parent) LineItem(example.LineItem) ExceptionThrowingBean(example.ExceptionThrowingBean) Book(example.Book) DataStoreTransaction(com.yahoo.elide.core.datastore.DataStoreTransaction) FunWithPermissions(example.FunWithPermissions) Child(example.Child) HashSet(java.util.HashSet) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with User

use of example.User in project elide by yahoo.

the class ResourceIT method elideSecurityEnabled.

@Test
public void elideSecurityEnabled() {
    Elide elide = new Elide(new ElideSettingsBuilder(dataStore).withEntityDictionary(EntityDictionary.builder().checks(TestCheckMappings.MAPPINGS).build()).withAuditLogger(new TestAuditLogger()).build());
    elide.doScans();
    com.yahoo.elide.core.security.User user = new com.yahoo.elide.core.security.User(() -> "-1");
    ElideResponse response = elide.get(baseUrl, "parent/1/children", new MultivaluedHashMap<>(), user, NO_VERSION);
    assertEquals(HttpStatus.SC_OK, response.getResponseCode());
    assertEquals("{\"data\":[]}", response.getBody());
}
Also used : ElideSettingsBuilder(com.yahoo.elide.ElideSettingsBuilder) User(example.User) ElideResponse(com.yahoo.elide.ElideResponse) TestAuditLogger(com.yahoo.elide.core.audit.TestAuditLogger) Elide(com.yahoo.elide.Elide) Test(org.junit.jupiter.api.Test) IntegrationTest(com.yahoo.elide.initialization.IntegrationTest) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

User (example.User)2 Elide (com.yahoo.elide.Elide)1 ElideResponse (com.yahoo.elide.ElideResponse)1 ElideSettingsBuilder (com.yahoo.elide.ElideSettingsBuilder)1 TestAuditLogger (com.yahoo.elide.core.audit.TestAuditLogger)1 DataStoreTransaction (com.yahoo.elide.core.datastore.DataStoreTransaction)1 IntegrationTest (com.yahoo.elide.initialization.IntegrationTest)1 Address (example.Address)1 Book (example.Book)1 Child (example.Child)1 Company (example.Company)1 ExceptionThrowingBean (example.ExceptionThrowingBean)1 FunWithPermissions (example.FunWithPermissions)1 Invoice (example.Invoice)1 LineItem (example.LineItem)1 Parent (example.Parent)1 HashSet (java.util.HashSet)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 Test (org.junit.jupiter.api.Test)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1