<commit_before>/*
 * Copyright 2008 The Kuali Foundation.
 * 
 * Licensed under the Educational Community License, Version 1.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/ecl1.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.kfs.module.cam.document.service;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Map;

import org.kuali.core.service.impl.BusinessObjectServiceImpl;
import org.kuali.core.util.DateUtils;
import org.kuali.kfs.module.cam.businessobject.Asset;
import org.kuali.kfs.module.cam.document.EquipmentLoanOrReturnDocument;
import org.kuali.kfs.module.cam.document.service.impl.EquipmentLoanInfoServiceImpl;
import org.kuali.kfs.sys.KFSConstants;
import org.kuali.kfs.sys.businessobject.FinancialSystemDocumentHeader;
import org.kuali.kfs.sys.context.KualiTestBase;

public class EquipmentLoanInfoServiceTest extends KualiTestBase {
    private static final int THREE_DAYS_LATER = 3;
    private static final int TWO_DAYS_LATER = 2;
    private EquipmentLoanInfoServiceImpl equipmentLoanInfoService;
    private Asset asset;

    private static EquipmentLoanOrReturnDocument createEquipmentLoanDoc(int loanDaysToadd, String docStatus) {
        EquipmentLoanOrReturnDocument doc = new EquipmentLoanOrReturnDocument() {
            @Override
            public void refreshReferenceObject(String referenceObjectName) {
            }
        };
        doc.setLoanDate(new java.sql.Date((DateUtils.addDays(new Date(), loanDaysToadd)).getTime()));
        FinancialSystemDocumentHeader header = new FinancialSystemDocumentHeader();
        header.setFinancialDocumentStatusCode(docStatus);
        doc.setDocumentHeader(header);
        return doc;
    }

    @Override
    protected void setUp() throws Exception {
        super.setUp();
        equipmentLoanInfoService = new EquipmentLoanInfoServiceImpl();
        equipmentLoanInfoService.setBusinessObjectService(new BusinessObjectServiceImpl() {
            @Override
            public Collection findMatching(Class clazz, Map fieldValues) {
                List<EquipmentLoanOrReturnDocument> docs = new ArrayList<EquipmentLoanOrReturnDocument>();
                docs.add(createEquipmentLoanDoc(3, KFSConstants.DocumentStatusCodes.APPROVED));
                docs.add(createEquipmentLoanDoc(5, KFSConstants.DocumentStatusCodes.APPROVED));
                docs.add(createEquipmentLoanDoc(5, KFSConstants.DocumentStatusCodes.DISAPPROVED));
                return docs;<commit_msg>Fixed error in EquipmentLoanInfoServiceTest<commit_after>/*
 * Copyright 2008 The Kuali Foundation.
 * 
 * Licensed under the Educational Community License, Version 1.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/ecl1.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.kfs.module.cam.document.service;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Map;

import org.kuali.core.service.impl.BusinessObjectServiceImpl;
import org.kuali.core.util.DateUtils;
import org.kuali.kfs.module.cam.businessobject.Asset;
import org.kuali.kfs.module.cam.document.EquipmentLoanOrReturnDocument;
import org.kuali.kfs.module.cam.document.service.impl.EquipmentLoanInfoServiceImpl;
import org.kuali.kfs.sys.ConfigureContext;
import org.kuali.kfs.sys.KFSConstants;
import org.kuali.kfs.sys.businessobject.FinancialSystemDocumentHeader;
import org.kuali.kfs.sys.context.KualiTestBase;
import org.kuali.kfs.sys.fixture.UserNameFixture;

public class EquipmentLoanInfoServiceTest extends KualiTestBase {
    private static final int THREE_DAYS_LATER = 3;
    private static final int TWO_DAYS_LATER = 2;
    private EquipmentLoanInfoServiceImpl equipmentLoanInfoService;
    private Asset asset;

    private static EquipmentLoanOrReturnDocument createEquipmentLoanDoc(int loanDaysToadd, String docStatus) {
        EquipmentLoanOrReturnDocument doc = new EquipmentLoanOrReturnDocument() {
            @Override
            public void refreshReferenceObject(String referenceObjectName) {
            }
        };
        doc.setLoanDate(new java.sql.Date((DateUtils.addDays(new Date(), loanDaysToadd)).getTime()));
        FinancialSystemDocumentHeader header = new FinancialSystemDocumentHeader();
        header.setFinancialDocumentStatusCode(docStatus);
        doc.setDocumentHeader(header);
        return doc;
    }

    @Override
    @ConfigureContext(session = UserNameFixture.KHUNTLEY, shouldCommitTransactions = false)
    protected void setUp() throws Exception {
        super.setUp();
        equipmentLoanInfoService = new EquipmentLoanInfoServiceImpl();
        equipmentLoanInfoService.setBusinessObjectService(new BusinessObjectServiceImpl() {
            @Override
            public Collection findMatching(Class clazz, Map fieldValues) {
                List<EquipmentLoanOrReturnDocument> docs = new ArrayList<EquipmentLoanOrReturnDocument>();
                docs.add(createEquipmentLoanDoc(3, KFSConstants.DocumentStatusCodes.APPROVED));
                docs.add(createEquipmentLoanDoc(5, KFSConstants.DocumentStatusCodes.APPROVED));
                docs.add(createEquipmentLoanDoc(5, KFSConstants.DocumentStatusCodes.DISAPPROVED));
                return docs;
{'fraction_non_alphanumeric': 0.07819401275969246, 'fraction_numerical': 0.003926059218059872, 'mean_word_length': 4.069651741293533, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '1094016', 'n_tokens_mistral': 1738, 'n_tokens_neox': 1672, 'n_words': 400}