Package se.gu.fire.core

Examples of se.gu.fire.core.Submission$Builder



        // Test adding submission and a file
        byte[] text = "Java, Lava\nNava".getBytes();
       
        Submission sub = new Submission.Builder()
                .assignment(assign)
                .submittingGroup(group)
                .grader(u2)
                .build();
       
        em.getTransaction().begin();
        sm.create(sub);
        em.getTransaction().commit();
        assertEquals(SubmissionStatus.New, sm.getAssignmentStatus(assign, group));

        Comment com = new Comment(u2, "Total katastrof! Bara Christopher kan rädda dig nu");

        sub.addComments(com);
        sub.addFile(new StoredFile("Hacker.java", text, "text/plain"));
        Submission sub2 = sm.read(sub.getId());

        assertEquals(sub, sub2);

        // Test setSubmissionStatus()
        sub.setSubmissionStatus(SubmissionStatus.Rejected);
        em.getTransaction().begin();
        sm.update(sub);
        em.getTransaction().commit();

        assertEquals(SubmissionStatus.Rejected, sm.getAssignmentStatus(assign, group));

        // Ensure comment exits
        assertTrue(sub2.getComments().size() > 0);

        // Ensure files exists
        List<StoredFile> files = sm.getSubmissionFiles(sub);
        assertTrue(files.size() > 0);

        sub = sm.read(sub.getId());
        assertEquals(SubmissionStatus.Rejected, sub.getSubmissionStatus());

        // Test getAllByGroup()
        Submission subAgain = new Submission.Builder()
                .assignment(assign)
                .submittingGroup(group)
                .grader(u2)
                .build();

        em.getTransaction().begin();
        sm.create(subAgain);
        em.getTransaction().commit();
        List<Submission> allGroupSub = sm.getAllByGroup(group);
        assertNotNull(allGroupSub);
        assertTrue(allGroupSub.size() >= 2);

        // Test getALlByGroup(Assignment, Group)
        allGroupSub = sm.getAllByGroup(assign, group);
        assertNotNull(allGroupSub);
        assertTrue(allGroupSub.size() >= 2);

        // Test submission with no grader doesn't give NPE
        subAgain = new Submission.Builder()
                .assignment(assign)
                .submittingGroup(group)
                .build();

        em.getTransaction().begin();
        sm.create(subAgain);
        em.getTransaction().commit();
       
        List<Submission> assignedSub = sm.getAllForGrader(assign, u2);
        assertNotNull(assignedSub);
        assertTrue(assignedSub.size() >= 2);

        // Test for isPassed
        subAgain.setSubmissionStatus(SubmissionStatus.Accepted);

        em.getTransaction().begin();
        sm.update(subAgain);
        em.getTransaction().commit();
       
View Full Code Here


                        new FacesMessage(FacesMessage.SEVERITY_ERROR,
                            "Submission not allowed because no files are uploaded.", null));
                return null;
        }

        Submission sub = new Submission.Builder()
                .assignment(assign)
                .submittingGroup(group)
                .build();

        for (UploadedFile file : getUploadedFiles()) {
            sub.addFile(new StoredFile(file.getFileName(),
                    file.getContents(), file.getContentType()));
        }

        FireLogger.logInfo(uploadedFiles.toString());
View Full Code Here

        FireLogger.logInfo("Created new SubmissionManager");
    }
  
    @Override
    public boolean isPassed(Assignment assignment, StudentGroup group) {
        Submission all = null;
        try {
            String query =
                     "select s from Submission s where "
                   + "s.submittingGroup.id = :groupId "
                   + "and s.assignment.id = :assignId "
View Full Code Here

TOP

Related Classes of se.gu.fire.core.Submission$Builder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.