Package com.darkhonor.rage.model

Examples of com.darkhonor.rage.model.Category


        gevent.setPartialCredit(false);
        gevent.setTerm("Spring 2010");
        gevent.setVersion("ALL");

        Query query = em.createQuery("SELECT c FROM Category c");
        Category dbCat;
        try
        {
            dbCat = (Category) query.getSingleResult();
        } catch (NoResultException ex)
        {
            dbCat = new Category("Array");
            em.getTransaction().begin();
            em.persist(dbCat);
            em.getTransaction().commit();
        }
View Full Code Here


    @Test
    @Ignore
    public void testGetAllQuestionsInCategory()
    {
        System.out.println("getAllQuestionsInCategory");
        Category category = null;
        List expResult = null;
        List result = instance.getAllQuestionsInCategory(category);
        assertEquals(expResult, result);
        // TODO review the generated test code and remove the default call to fail.
        fail("The test case is a prototype.");
View Full Code Here

    {
        persistDatabaseVersion(new Double(2.1));
        Course course1 = createTestCourse();
        Course course2 = createSecondCourse();

        Category category1 = createPersistedCategory(1L, "Array");
        Category category2 = createPersistedCategory(2L, "Loop");
        Category category3 = createPersistedCategory(3L, "Iteration");
        // Create some specific TestCases to start with that can be used for testing
        // createPersistedQuestion does this as well, but with unpredictable
        // TestCase id values
        TestCase testCase1 = new TestCase(new BigDecimal("1.0"));
        testCase1.setId(new Long(5L));
View Full Code Here

    }

    private Category createPersistedCategory(Long id, String name)
    {
        EntityManager em = emf.createEntityManager();
        Category category = null;
       
        try
        {
            category = findCategoryByName(name);
            LOGGER.warn("Category already exists: " + category);
        } catch (NoResultException ex)
        {
            category = new Category(name);
            category.setId(id);
            EntityTransaction tx = em.getTransaction();
            tx.begin();
            em.persist(category);
            tx.commit();
            LOGGER.debug("Category Id (post-persist): " + category.getId());
        }
        em.close();
        return category;
    }
View Full Code Here

            /** Set the question category--this is not a nullable field
             *  This button will not activate if the txtCategory field is null or
             *  empty, so we can safely not check for it here.
             */
            question.setCategory(new Category(txtCategory.getText()));

            /**
             * As long as there are test cases, we can continue...otherwise stop
             */
            if (modTCList.getSize() > 0)
View Full Code Here

                        //Root<Category> categoryRoot = cq.from(Category.class);
                        //cq.where(cb.equal(categoryRoot.get("name"),
                        //      txtCategory.getText().trim()));
                        //TypedQuery<Category> categoryQuery = em.createQuery(cq);
                        CategoryDAO catDAO = new CategoryDAO(emf.createEntityManager());
                        Category queryCat;
                        try
                        {
                            //queryCat = categoryQuery.getSingleResult();
                            queryCat = catDAO.find(txtCategory.getText().trim());
                            LOGGER.info("Category already exists in database: "
                                    + queryCat.getName());
                        } catch (NoResultException ex)
                        {
                            queryCat = new Category(txtCategory.getText().trim());
                            //tx.begin();
                            //em.persist(queryCat);
                            //tx.commit();
                            Long newCatId = catDAO.create(queryCat);
                            queryCat.setId(newCatId);
                            LOGGER.info("Added Category: " + queryCat.getName());
                        }
                        question.setCategory(queryCat);
                        if (catDAO.isOpen())
                        {
                            catDAO.closeConnection();
View Full Code Here

            //Set the description field with the description of the question
            txtDescription.setText(question.getDescription());
            //Use a tempory category object to grab the name of the category as
            // a string and set the category text box to that catgory name
            Category tempCategory = question.getCategory();
            txtCategory.setText(tempCategory.getName());
            txtValue.setText(questionValue.toPlainString());
            em.close();
        }

    }//GEN-LAST:event_btnEditQuestionAction
View Full Code Here

    public void testFindId()
    {
        System.out.println("findId");
        assertTrue(instance.isOpen());
        Long resultId = new Long(2L);
        Category result = instance.find(resultId);
        assertEquals("Loop", result.getName());
        Long expectedId = new Long(resultId);
        assertEquals(expectedId, result.getId());
    }
View Full Code Here

    public void testFindIdNoResult()
    {
        System.out.println("findIdNoResult");
        assertTrue(instance.isOpen());
        Long resultId = new Long(12L);
        Category result = instance.find(resultId);
        assertNull(result);
    }
View Full Code Here

    public void testFindIdLessThanZero()
    {
        System.out.println("findIdLessThanZero");
        assertTrue(instance.isOpen());
        Long resultId = new Long(-3L);
        Category result = instance.find(resultId);
    }
View Full Code Here

TOP

Related Classes of com.darkhonor.rage.model.Category

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.