Search in sources :

Example 1 with Assignment

use of com.instructure.canvasapi2.models.Assignment in project instructure-android by instructure.

the class AssignmentUtils2Test method getAssignmentState_unknownStateNullAssignment.

@Test
public void getAssignmentState_unknownStateNullAssignment() throws Exception {
    Assignment assignment = null;
    Submission submission = new Submission();
    int testValue = AssignmentUtils2.getAssignmentState(assignment, submission);
    assertEquals("", testValue, AssignmentUtils2.ASSIGNMENT_STATE_UNKNOWN);
}
Also used : Assignment(com.instructure.canvasapi2.models.Assignment) Submission(com.instructure.canvasapi2.models.Submission) Test(org.junit.Test)

Example 2 with Assignment

use of com.instructure.canvasapi2.models.Assignment in project instructure-android by instructure.

the class AssignmentUtils2Test method getAssignmentState_stateInClass.

@Test
public void getAssignmentState_stateInClass() throws Exception {
    Assignment assignment = new Assignment();
    Submission submission = null;
    long time = Calendar.getInstance().getTimeInMillis() + 100000;
    Date date = new Date(time);
    ArrayList<String> submissionTypes = new ArrayList<>();
    submissionTypes.add(Assignment.submissionTypeToAPIString(Assignment.SUBMISSION_TYPE.ON_PAPER));
    assignment.setSubmission(submission);
    assignment.setDueAt(APIHelper.dateToString(date));
    assignment.setSubmissionTypes(submissionTypes);
    int testValue = AssignmentUtils2.getAssignmentState(assignment, submission);
    assertEquals("", testValue, AssignmentUtils2.ASSIGNMENT_STATE_IN_CLASS);
}
Also used : Assignment(com.instructure.canvasapi2.models.Assignment) Submission(com.instructure.canvasapi2.models.Submission) ArrayList(java.util.ArrayList) Date(java.util.Date) Test(org.junit.Test)

Example 3 with Assignment

use of com.instructure.canvasapi2.models.Assignment in project instructure-android by instructure.

the class AssignmentUtils2Test method getAssignmentState_stateGraded.

@Test
public void getAssignmentState_stateGraded() throws Exception {
    Assignment assignment = new Assignment();
    Submission submission = new Submission();
    long time = Calendar.getInstance().getTimeInMillis() + 100000;
    Date date = new Date(time);
    submission.setAttempt(1);
    submission.setGrade("A");
    assignment.setSubmission(submission);
    assignment.setDueAt(APIHelper.dateToString(date));
    int testValue = AssignmentUtils2.getAssignmentState(assignment, submission);
    assertEquals("", testValue, AssignmentUtils2.ASSIGNMENT_STATE_GRADED);
}
Also used : Assignment(com.instructure.canvasapi2.models.Assignment) Submission(com.instructure.canvasapi2.models.Submission) Date(java.util.Date) Test(org.junit.Test)

Example 4 with Assignment

use of com.instructure.canvasapi2.models.Assignment in project instructure-android by instructure.

the class AssignmentUtils2Test method getAssignmentState_stateMissingNullDueDate.

@Test
public void getAssignmentState_stateMissingNullDueDate() throws Exception {
    Assignment assignment = new Assignment();
    Submission submission = null;
    assignment.setSubmission(submission);
    assignment.setDueAt(null);
    int testValue = AssignmentUtils2.getAssignmentState(assignment, submission);
    assertEquals("", testValue, AssignmentUtils2.ASSIGNMENT_STATE_MISSING);
}
Also used : Assignment(com.instructure.canvasapi2.models.Assignment) Submission(com.instructure.canvasapi2.models.Submission) Test(org.junit.Test)

Example 5 with Assignment

use of com.instructure.canvasapi2.models.Assignment in project instructure-android by instructure.

the class ViewUtilsTest method getAssignmentIcon_OTHERS.

@Test
public void getAssignmentIcon_OTHERS() throws Exception {
    Assignment assignment = new Assignment();
    List<String> types = new ArrayList<>();
    types.add(submissionTypeToAPIString(Assignment.SUBMISSION_TYPE.NONE));
    types.add(submissionTypeToAPIString(Assignment.SUBMISSION_TYPE.ON_PAPER));
    types.add(submissionTypeToAPIString(Assignment.SUBMISSION_TYPE.EXTERNAL_TOOL));
    types.add(submissionTypeToAPIString(Assignment.SUBMISSION_TYPE.ONLINE_UPLOAD));
    types.add(submissionTypeToAPIString(Assignment.SUBMISSION_TYPE.ONLINE_TEXT_ENTRY));
    types.add(submissionTypeToAPIString(Assignment.SUBMISSION_TYPE.ONLINE_URL));
    types.add(submissionTypeToAPIString(Assignment.SUBMISSION_TYPE.MEDIA_RECORDING));
    types.add(submissionTypeToAPIString(Assignment.SUBMISSION_TYPE.ATTENDANCE));
    types.add(submissionTypeToAPIString(Assignment.SUBMISSION_TYPE.NOT_GRADED));
    assignment.setSubmissionTypes(types);
    @DrawableRes int iconRes = ViewUtils.getAssignmentIcon(assignment);
    assertTrue(iconRes == R.drawable.ic_cv_assignments_fill);
}
Also used : Assignment(com.instructure.canvasapi2.models.Assignment) DrawableRes(android.support.annotation.DrawableRes) ArrayList(java.util.ArrayList) Assignment.submissionTypeToAPIString(com.instructure.canvasapi2.models.Assignment.submissionTypeToAPIString) Test(org.junit.Test)

Aggregations

Assignment (com.instructure.canvasapi2.models.Assignment)62 Test (org.junit.Test)46 Submission (com.instructure.canvasapi2.models.Submission)25 Date (java.util.Date)18 ArrayList (java.util.ArrayList)15 View (android.view.View)10 RestBuilder (com.instructure.canvasapi2.builders.RestBuilder)10 Course (com.instructure.canvasapi2.models.Course)9 RestParams (com.instructure.canvasapi2.builders.RestParams)7 Bundle (android.os.Bundle)6 ScheduleItem (com.instructure.canvasapi2.models.ScheduleItem)6 LinkHeaders (com.instructure.canvasapi2.utils.LinkHeaders)6 Navigation (com.instructure.interactions.Navigation)5 DrawableRes (android.support.annotation.DrawableRes)4 AdapterView (android.widget.AdapterView)4 TextView (android.widget.TextView)4 Request (okhttp3.Request)4 Response (okhttp3.Response)4 Paint (android.graphics.Paint)3 Drawable (android.graphics.drawable.Drawable)3