<commit_before>/**
 * Copyright 2005-2014 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.krad.demo.uif.library.collections;

import org.junit.Test;

import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase;

/**
 * @author Kuali Rice Team (<EMAIL>)
 */
public class LibraryCollectionFeaturesEditLineAft extends WebDriverLegacyITBase {

    /**
     * /kr-krad/kradsampleapp?viewId=Demo-CollectionEditLineView
     */
    public static final String BOOKMARK_URL = "/kr-krad/kradsampleapp?viewId=Demo-CollectionEditLineView";
    public static final int FIVE_SECOND_WAIT_TIME = 5;

    @Override
    protected String getBookmarkUrl() {
        return BOOKMARK_URL;
    }

    @Override
    protected void navigate() throws Exception {
        waitAndClickLibraryLink();
        waitAndClickByLinkText("Collection Features");
        waitAndClickByLinkText("Edit Line");
    }
    
    protected void testDefaultEditLine() throws Exception {
    	testAllFeatures("Demo-CollectionEditLine-Example1", "collection1[0].field1", "collection1[0].field2");
    }
    
    protected void testCustomDialogEditLine1() throws Exception {
    	waitAndSelectByName("exampleShown", "Custom Dialog Edit Line 1");
    	testAllFeatures("Demo-CollectionEditLine-Example2", "collection2[0].field1", null);
    }
    
    protected void testCustomDialogEditLine2() throws Exception {
    	waitAndSelectByName("exampleShown", "Custom Dialog Edit Line 2");
    	testAllFeatures("Demo-CollectionEditLine-Example3","collection3[0].field3",null);
    }
    
    protected void testCustomDialogLineActionEditLine() throws Exception {
    	waitAndSelectByName("exampleShown", "Custom Dialog Line Action Edit Line");
    	testAllFeatures("Demo-CollectionEditLine-Example4","collection1_4[0].field1","collection1_4[0].field2");
    }
    
    protected void testCustomDialogSaveActionEditLine() throws Exception {
    	waitAndSelectByName("exampleShown", "Custom Dialog Save Action Edit Line");
    	testCustomDialogSaveActionEditLineFeatures("Demo-CollectionEditLine-Example5", "collection6[0].field1",
                "collection6[0].field2");
    }
    
    protected void testReadOnlyEditLine() throws Exception {
    	waitAndSelectByName("exampleShown", "ReadOnly Edit Line");
//    	testAllFeatures("Demo-CollectionEditLine-Example6",null,null);
    }
    
    protected void testEditAuthorizationEditLineCollectionReadOnly() throws Exception {
    	waitAndSelectByName("exampleShown", "Edit Authorization Edit Line (collection readOnly)");
     	testEditAuthorizationEditLineCollectionReadOnlyFeatures("Demo-CollectionEditLine-Example7");
    }

    protected void testEditAuthorizationEditLineLineAuthorization() throws Exception {
    	waitAndSelectByName("exampleShown", "Edit Authorization Edit Line (line authorization)");
   	    testEditAuthorizationEditLineLineAuthorizationFeatures("Demo-CollectionEditLine-Example8");
    }
    
    protected void testLookupCollectionEditLine() throws Exception {
    	waitAndSelectByName("exampleShown", "Lookup Collection Edit Line");
    	testLookupCollectionEditLineFeatures("Demo-CollectionEditLine-Example9");
    }

    protected void testCollectionFeaturesEditLine() throws Exception {
        testDefaultEditLine();
        testCustomDialogEditLine1();
        testCustomDialogEditLine2();
        testCustomDialogLineActionEditLine();
        testCustomDialogSaveActionEditLine();
        testReadOnlyEditLine();
        testEditAuthorizationEditLineCollectionReadOnly();
        testEditAuthorizationEditLineLineAuthorization();
        testLookupCollectionEditLine();
    }

    protected void testAllFeatures(String sectionDataParent, String firstFieldToEdit, String secondFieldToEdit)
            throws Exception {

        //Generate random four digit numbers
        String randomNumberString = generate4DigitRandomNumber();
        String randomNumberString2 = generate4DigitRandomNumber();
        String randomNumberString3 = generate4DigitRandomNumber();

        addAndVerify(sectionDataParent, randomNumberString);

        editAndSave(sectionDataParent, randomNumberString2, firstFieldToEdit, secondFieldToEdit);

        if (firstFieldToEdit != null && secondFieldToEdit != null) {
            jGrowl("Since we could edit both fields, verify " + randomNumberString + " is not present");
            waitForTextNotPresent(randomNumberString);
        }
        waitForTextPresent(randomNumberString2);

        editAndCancel(sectionDataParent, randomNumberString3, firstFieldToEdit, secondFieldToEdit);

        if (firstFieldToEdit != null && secondFieldToEdit != null) {
            jGrowl("Since we could edit both fields, verify " + randomNumberString + " is not present");
            waitForTextNotPresent(randomNumberString);
        }

        waitForTextPresent(randomNumberString2);
    }

    protected void testCustomDialogSaveActionEditLineFeatures(String sectionDataParent, String firstFieldToEdit,
            String secondFieldToEdit) throws Exception {
        //Generate random four digit numbers
        String randomNumberString = generate4DigitRandomNumber();<commit_msg>RICEQA-552 : CI Analysis QA 2.5.0-rc Sprint 1 -  aft update<commit_after>/**
 * Copyright 2005-2014 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.krad.demo.uif.library.collections;

import org.junit.Test;

import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase;

/**
 * @author Kuali Rice Team (<EMAIL>)
 */
public class LibraryCollectionFeaturesEditLineAft extends WebDriverLegacyITBase {

    /**
     * /kr-krad/kradsampleapp?viewId=Demo-CollectionEditLineView
     */
    public static final String BOOKMARK_URL = "/kr-krad/kradsampleapp?viewId=Demo-CollectionEditLineView";
    public static final int FIVE_SECOND_WAIT_TIME = 5;

    @Override
    protected String getBookmarkUrl() {
        return BOOKMARK_URL;
    }

    @Override
    protected void navigate() throws Exception {
        waitAndClickLibraryLink();
        waitAndClickByLinkText("Collection Features");
        waitAndClickByLinkText("Edit Line");
    }
    
    protected void testDefaultEditLine() throws Exception {
    	testAllFeatures("Demo-CollectionEditLine-Example1", "collection1[0].field1", "collection1[0].field2");
    }
    
    protected void testCustomDialogEditLine1() throws Exception {
    	waitAndSelectByName("exampleShown", "Custom Dialog Edit Line 1");
    	testAllFeatures("Demo-CollectionEditLine-Example2", "collection2[0].field1", null);
    }
    
    protected void testCustomDialogEditLine2() throws Exception {
    	waitAndSelectByName("exampleShown", "Custom Dialog Edit Line 2");
    	testAllFeatures("Demo-CollectionEditLine-Example3","collection3[0].field3",null);
    }
    
    protected void testCustomDialogLineActionEditLine() throws Exception {
    	waitAndSelectByName("exampleShown", "Custom Dialog Line Action Edit Line");
    	testAllFeatures("Demo-CollectionEditLine-Example4","collection1_4[0].field1","collection1_4[0].field2");
    }
    
    protected void testCustomDialogSaveActionEditLine() throws Exception {
    	waitAndSelectByName("exampleShown", "Custom Dialog Save Action Edit Line");
    	testCustomDialogSaveActionEditLineFeatures("Demo-CollectionEditLine-Example5", "collection6[0].field1",
                "collection6[0].field2");
    }
    
    protected void testReadOnlyEditLine() throws Exception {
    	waitAndSelectByName("exampleShown", "ReadOnly Edit Line");
//    	testAllFeatures("Demo-CollectionEditLine-Example6",null,null);
    }
    
    protected void testEditAuthorizationEditLineCollectionReadOnly() throws Exception {
    	waitAndSelectByName("exampleShown", "Edit Authorization Edit Line (collection readOnly)");
     	testEditAuthorizationEditLineCollectionReadOnlyFeatures("Demo-CollectionEditLine-Example7");
    }

    protected void testEditAuthorizationEditLineLineAuthorization() throws Exception {
    	waitAndSelectByName("exampleShown", "Edit Authorization Edit Line (line authorization)");
   	    testEditAuthorizationEditLineLineAuthorizationFeatures("Demo-CollectionEditLine-Example8");
    }
    
    protected void testLookupCollectionEditLine() throws Exception {
    	waitAndSelectByName("exampleShown", "Lookup Collection Edit Line");
    	testLookupCollectionEditLineFeatures("Demo-CollectionEditLine-Example9");
    }

    protected void testCollectionFeaturesEditLine() throws Exception {
        testDefaultEditLine();
        testCustomDialogEditLine1();
        testCustomDialogEditLine2();
        testCustomDialogLineActionEditLine();
        testCustomDialogSaveActionEditLine();
        testReadOnlyEditLine();
        testEditAuthorizationEditLineCollectionReadOnly();
        testEditAuthorizationEditLineLineAuthorization();
        testLookupCollectionEditLine();
    }

    protected void testAllFeatures(String sectionDataParent, String firstFieldToEdit, String secondFieldToEdit)
            throws Exception {

        //Generate random four digit numbers
        String randomNumberString = generate4DigitRandomNumber();
        String randomNumberString2 = generate4DigitRandomNumber();
        String randomNumberString3 = generate4DigitRandomNumber();

        addAndVerify(sectionDataParent, randomNumberString);

        editAndSave(sectionDataParent, randomNumberString2, firstFieldToEdit, secondFieldToEdit);

        if (firstFieldToEdit != null && secondFieldToEdit != null) {
            jGrowl("Since we could edit both fields, verify " + randomNumberString + " is not present");
            waitForProgressLoading();
            waitForTextNotPresent(randomNumberString);
        }
        waitForTextPresent(randomNumberString2);

        editAndCancel(sectionDataParent, randomNumberString3, firstFieldToEdit, secondFieldToEdit);

        if (firstFieldToEdit != null && secondFieldToEdit != null) {
            jGrowl("Since we could edit both fields, verify " + randomNumberString + " is not present");
            waitForTextNotPresent(randomNumberString);
        }

        waitForTextPresent(randomNumberString2);
    }

    protected void testCustomDialogSaveActionEditLineFeatures(String sectionDataParent, String firstFieldToEdit,
            String secondFieldToEdit) throws Exception {
        //Generate random four digit numbers
        String randomNumberString = generate4DigitRandomNumber();
{'fraction_non_alphanumeric': 0.0829857490441432, 'fraction_numerical': 0.011557177615571776, 'mean_word_length': 4.174910071942446, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '6446421', 'n_tokens_mistral': 2958, 'n_tokens_neox': 2919, 'n_words': 692}