<commit_before>/**
 * Copyright 2005-2011 The Kuali Foundation
 *
 * Licensed under the Educational Community License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.opensource.org/licenses/ecl2.php
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.kuali.rice.ken.dao;

import org.kuali.rice.ken.bo.NotificationChannel;
import org.kuali.rice.ken.bo.NotificationChannelReviewer;
import org.kuali.rice.ken.test.util.MockObjectsUtil;
import org.kuali.rice.ken.util.NotificationConstants;
import org.kuali.rice.kim.api.KimConstants.KimGroupMemberTypes;

import java.util.HashMap;

/**
 * This class tests basic persistence for the {@link NotificationChannelReviewer} business object.
 *
 * @author <NAME> (<EMAIL>)
 */
public class NotificationChannelReviewerDaoTest extends BusinessObjectPersistenceTestCaseBase {
    private NotificationChannel mockChannel1 = MockObjectsUtil.getTestChannel1();
    private NotificationChannelReviewer mockReviewer = MockObjectsUtil.buildTestNotificationChannelReviewer(KimGroupMemberTypes.PRINCIPAL_MEMBER_TYPE, "aReviewer");

    /**
     * @see org.kuali.rice.ken.dao.BusinessObjectPersistenceTestCaseBase#setup()
     */
    @Override
    protected void setup() {
        super.setup();
        businessObjectDao.save(mockChannel1);
    }

    /**
     * @see org.kuali.rice.ken.dao.BusinessObjectPersistenceTestCaseBase#delete()
     */
    @Override
    protected boolean delete() {
        HashMap criteria = new HashMap();

        criteria.put(NotificationConstants.BO_PROPERTY_NAMES.REVIEWER_ID, mockReviewer.getReviewerId());
        NotificationChannelReviewer reviewer = (NotificationChannelReviewer) businessObjectDao.findByUniqueKey(NotificationChannelReviewer.class, criteria);

        try {
            businessObjectDao.delete(reviewer);
        } catch(Exception e) {
            return false;
        }
        return true;
    }


    /**
     * @see org.kuali.rice.ken.dao.BusinessObjectPersistenceTestCaseBase#insert()
     */
    @Override
    protected boolean insert() {
        mockReviewer.setChannel(mockChannel1);

        try {
            businessObjectDao.save(mockReviewer);
        } catch(Exception e) {
            return false;
        }
        return true;
    }

    /**
     * @see org.kuali.rice.ken.dao.BusinessObjectPersistenceTestCaseBase#retrieve()
     */
    @Override
    protected boolean retrieve() {
        HashMap criteria = new HashMap();

        criteria.put(NotificationConstants.BO_PROPERTY_NAMES.REVIEWER_ID, mockReviewer.getReviewerId());
        NotificationChannelReviewer reviewer = (NotificationChannelReviewer) businessObjectDao.findByUniqueKey(NotificationChannelReviewer.class, criteria);

        boolean success = true;

        success &= reviewer != null;
        success &= reviewer.getReviewerId().equals(mockReviewer.getReviewerId());
        success &= reviewer.getReviewerType().equals(mockReviewer.getReviewerType());
        success &= reviewer.getChannel() != null;
        success &= reviewer.getChannel().getId().equals(mockChannel1.getId());

        return success;
    }

    /**
     * @see org.kuali.rice.ken.dao.BusinessObjectPersistenceTestCaseBase#update()
     */
    @Override
    protected boolean update() {
        HashMap criteria = new HashMap();

        criteria.put(NotificationConstants.BO_PROPERTY_NAMES.REVIEWER_ID, mockReviewer.getReviewerId());
        NotificationChannelReviewer reviewer = (NotificationChannelReviewer) businessObjectDao.findByUniqueKey(NotificationChannelReviewer.class, criteria);

        reviewer.setReviewerId("updatedReviewerId");
        reviewer.setReviewerType(KimGroupMemberTypes.GROUP_MEMBER_TYPE.getCode());

        try {
            businessObjectDao.save(reviewer);
        } catch(Exception e) {
            return false;
        }
        return true;
    }

    /**
     * @see org.kuali.rice.ken.dao.BusinessObjectPersistenceTestCaseBase#validateChanges()
     */
    @Override
    protected boolean validateChanges() {
        NotificationChannelReviewer reviewer = (NotificationChannelReviewer) businessObjectDao.findById(NotificationChannelReviewer.class, mockReviewer.getId());

        boolean success = reviewer != null;
        success &= reviewer.getReviewerId().equals("updatedReviewerId");
        success &= reviewer.getReviewerType().equals(KimGroupMemberTypes.GROUP_MEMBER_TYPE);

        return success;
    }
}<commit_msg>KULRICE-5658 fix membertype enum bug<commit_after>/**
 * Copyright 2005-2011 The Kuali Foundation
 *
 * Licensed under the Educational Community License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.opensource.org/licenses/ecl2.php
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.kuali.rice.ken.dao;

import org.kuali.rice.ken.bo.NotificationChannel;
import org.kuali.rice.ken.bo.NotificationChannelReviewer;
import org.kuali.rice.ken.test.util.MockObjectsUtil;
import org.kuali.rice.ken.util.NotificationConstants;
import org.kuali.rice.kim.api.KimConstants.KimGroupMemberTypes;

import java.util.HashMap;

/**
 * This class tests basic persistence for the {@link NotificationChannelReviewer} business object.
 *
 * @author Kuali Rice Team (<EMAIL>)
 */
public class NotificationChannelReviewerDaoTest extends BusinessObjectPersistenceTestCaseBase {
    private NotificationChannel mockChannel1 = MockObjectsUtil.getTestChannel1();
    private NotificationChannelReviewer mockReviewer = MockObjectsUtil.buildTestNotificationChannelReviewer(KimGroupMemberTypes.PRINCIPAL_MEMBER_TYPE, "aReviewer");

    /**
     * @see org.kuali.rice.ken.dao.BusinessObjectPersistenceTestCaseBase#setup()
     */
    @Override
    protected void setup() {
        super.setup();
        businessObjectDao.save(mockChannel1);
    }

    /**
     * @see org.kuali.rice.ken.dao.BusinessObjectPersistenceTestCaseBase#delete()
     */
    @Override
    protected boolean delete() {
        HashMap criteria = new HashMap();

        criteria.put(NotificationConstants.BO_PROPERTY_NAMES.REVIEWER_ID, mockReviewer.getReviewerId());
        NotificationChannelReviewer reviewer = (NotificationChannelReviewer) businessObjectDao.findByUniqueKey(NotificationChannelReviewer.class, criteria);

        try {
            businessObjectDao.delete(reviewer);
        } catch(Exception e) {
            return false;
        }
        return true;
    }


    /**
     * @see org.kuali.rice.ken.dao.BusinessObjectPersistenceTestCaseBase#insert()
     */
    @Override
    protected boolean insert() {
        mockReviewer.setChannel(mockChannel1);

        try {
            businessObjectDao.save(mockReviewer);
        } catch(Exception e) {
            return false;
        }
        return true;
    }

    /**
     * @see org.kuali.rice.ken.dao.BusinessObjectPersistenceTestCaseBase#retrieve()
     */
    @Override
    protected boolean retrieve() {
        HashMap criteria = new HashMap();

        criteria.put(NotificationConstants.BO_PROPERTY_NAMES.REVIEWER_ID, mockReviewer.getReviewerId());
        NotificationChannelReviewer reviewer = (NotificationChannelReviewer) businessObjectDao.findByUniqueKey(NotificationChannelReviewer.class, criteria);

        boolean success = true;

        success &= reviewer != null;
        success &= reviewer.getReviewerId().equals(mockReviewer.getReviewerId());
        success &= reviewer.getReviewerType().equals(mockReviewer.getReviewerType());
        success &= reviewer.getChannel() != null;
        success &= reviewer.getChannel().getId().equals(mockChannel1.getId());

        return success;
    }

    /**
     * @see org.kuali.rice.ken.dao.BusinessObjectPersistenceTestCaseBase#update()
     */
    @Override
    protected boolean update() {
        HashMap criteria = new HashMap();

        criteria.put(NotificationConstants.BO_PROPERTY_NAMES.REVIEWER_ID, mockReviewer.getReviewerId());
        NotificationChannelReviewer reviewer = (NotificationChannelReviewer) businessObjectDao.findByUniqueKey(NotificationChannelReviewer.class, criteria);

        reviewer.setReviewerId("updatedReviewerId");
        reviewer.setReviewerType(KimGroupMemberTypes.GROUP_MEMBER_TYPE.getCode());

        try {
            businessObjectDao.save(reviewer);
        } catch(Exception e) {
            return false;
        }
        return true;
    }

    /**
     * @see org.kuali.rice.ken.dao.BusinessObjectPersistenceTestCaseBase#validateChanges()
     */
    @Override
    protected boolean validateChanges() {
        NotificationChannelReviewer reviewer = (NotificationChannelReviewer) businessObjectDao.findById(NotificationChannelReviewer.class, mockReviewer.getId());

        boolean success = reviewer != null;
        success &= reviewer.getReviewerId().equals("updatedReviewerId");
        success &= reviewer.getReviewerType().equals(KimGroupMemberTypes.GROUP_MEMBER_TYPE.getCode());

        return success;
    }
}
{'fraction_non_alphanumeric': 0.0961936284650393, 'fraction_numerical': 0.003723624327678941, 'mean_word_length': 3.533052039381153, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6747453', 'n_tokens_mistral': 2649, 'n_tokens_neox': 2491, 'n_words': 520}