Search in sources :

Example 56 with User

use of com.instructure.canvasapi2.models.User in project play-cookbook by spinscale.

the class SolrSearchTest method testQueryResultIds.

@Test
public void testQueryResultIds() {
    User u = User.find("byName", "alex").first();
    List<String> users = new Query("name:alex", User.class).fetchIds();
    assertEquals(u.id.toString(), users.get(0));
}
Also used : User(models.User) Query(play.modules.solr.Query) SolrQuery(org.apache.solr.client.solrj.SolrQuery) UnitTest(play.test.UnitTest) Test(org.junit.Test)

Example 57 with User

use of com.instructure.canvasapi2.models.User in project play-cookbook by spinscale.

the class CsvTest method readComplexEntityWithOtherEntites.

@Test
public void readComplexEntityWithOtherEntites() {
    User u = new User();
    u.name = "alex";
    u.currentCar = c;
    u.save();
    u = User.findById(1L);
    assertNotNull(u);
    assertEquals("alex", u.name);
    assertValidCar(u.currentCar, "BMW", "320");
}
Also used : User(models.User) UnitTest(play.test.UnitTest) Test(org.junit.Test)

Example 58 with User

use of com.instructure.canvasapi2.models.User in project play-cookbook by spinscale.

the class JsonRenderTest method testThatJsonRenderingWorks.

@Test
public void testThatJsonRenderingWorks() {
    Response response = GET("/user/1");
    assertIsOk(response);
    User user = new Gson().fromJson(getContent(response), User.class);
    assertNotNull(user);
    assertNull(user.password);
    assertNull(user.secrets);
    assertEquals(user.login, "alex");
    assertEquals(user.address.city, "Munich");
    assertContentMatch("\"uri\":\"/user/1\"", response);
}
Also used : Response(play.mvc.Http.Response) User(models.User) Gson(com.google.gson.Gson) FunctionalTest(play.test.FunctionalTest) Test(org.junit.Test)

Example 59 with User

use of com.instructure.canvasapi2.models.User in project play-cookbook by spinscale.

the class CsvTest method saveEntityWithLinkToAnother.

@Test
public void saveEntityWithLinkToAnother() throws Exception {
    User u = new User();
    u.name = "alex";
    u.currentCar = c;
    u.save();
    String data = FileUtils.readFileToString(new File("/tmp/User.csv"));
    String expected = "\"1\"\t\"alex\"\t\"#Car#1\"\n";
    assertEquals(expected, data);
}
Also used : User(models.User) File(java.io.File) UnitTest(play.test.UnitTest) Test(org.junit.Test)

Example 60 with User

use of com.instructure.canvasapi2.models.User in project play-cookbook by spinscale.

the class DigestRequest method isAuthorized.

public boolean isAuthorized() {
    User user = User.find("byName", params.get("username")).first();
    if (user == null) {
        throw new UnauthorizedDigest(params.get("realm"));
    }
    String digest = createDigest(user.apiPassword);
    return digest.equals(params.get("response"));
}
Also used : User(models.User)

Aggregations

User (models.User)30 User (com.instructure.canvasapi2.models.User)25 RestParams (com.instructure.canvasapi2.builders.RestParams)22 RestBuilder (com.instructure.canvasapi2.builders.RestBuilder)19 Test (org.junit.Test)16 LinkHeaders (com.instructure.canvasapi2.utils.LinkHeaders)8 CurrentUser (actions.CurrentUser)7 CurrentUser.currentUser (actions.CurrentUser.currentUser)7 NonNull (android.support.annotation.NonNull)7 View (android.view.View)7 List (java.util.List)7 Result (play.mvc.Result)7 ApiType (com.instructure.canvasapi2.utils.ApiType)6 ArrayList (java.util.ArrayList)6 Module (models.Module)6 UnitTest (play.test.UnitTest)6 Intent (android.content.Intent)5 RoleHolderPresent (be.objectify.deadbolt.actions.RoleHolderPresent)5 StatusCallback (com.instructure.canvasapi2.StatusCallback)5 Course (com.instructure.canvasapi2.models.Course)5