STest.java [test/service_tests] Revision:   Date:
package service_tests;

import csip.test.ServiceTest2;
import java.io.File;
import java.util.Properties;
import org.codehaus.jettison.json.JSONArray;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestName;

/**
 *
 * @author od
 */
public class STest {

    @Rule
    public TestName name = new TestName();
    
       //   Use this one to do a key/value pair matching test on the output. 
    private void runKeyValue() throws Exception {
        String testFolder = new File(getClass().getCanonicalName().replace('.', '/')).getParent();
        Properties myTestProperties = new Properties();
        myTestProperties.setProperty("csip.test.verify", "keyvalue");
        JSONArray r = ServiceTest2.run(myTestProperties, "test/" + testFolder + "/" + name.getMethodName() + ".json");
        Assert.assertTrue(r.getJSONObject(0).getInt("successful") == 1);
        Assert.assertFalse(r.getJSONObject(0).getJSONArray("tests").getJSONObject(0).getJSONObject("test").getJSONObject("result").has("differ"));
    }
    
    private void run() throws Exception {
        String testFolder = new File(getClass().getCanonicalName().replace('.', '/')).getParent();
        JSONArray r = ServiceTest2.run(new Properties(), "test/" + testFolder + "/" + name.getMethodName() + ".json");
        Assert.assertTrue(r.getJSONObject(0).getInt("successful") == 1);
    }

    /*
        1. Run a service against an endpoint.
        2. If successful, store the response in 'tests/service_tests'
        3. Name it : <servicepath>__<name>.json

            Example:
             The service response is 'alfafa.json' and ran
             successfully against 
                http://csip.engr.colostate.edu/csip-erosion/m/weps/1.3

            store this response as 
              tests/service_tests/m_weps_1_3__alfalfa.json

            - replace '/' with '_'
            - replace '.' with '_'
            - separate both parts with '__'

        4. Add a new JUnit test for this service to this file:

             @Test public void m_weps_1_3__alfalfa() throws Exception { 
               run(); 
             }

           The test method name and the name of the json file 
           (without the extension) must match!

           This is it! 
    */
    @Test public void  wqm01_m_wqsr_1_0__test1() throws Exception { runKeyValue(); }
    @Test public void  wqm01_m_wqsr_1_0__test2() throws Exception { runKeyValue(); }
    @Test public void  wqm01_m_wqsr_1_0__test3() throws Exception { runKeyValue(); }
    
    @Test public void  wqm02_m_wqmsoilattributes_1_0__ser_1() throws Exception { runKeyValue(); }
    @Test public void  wqm02_m_wqmsoilattributes_1_0__ser_2() throws Exception { runKeyValue(); }    
    @Test public void  wqm02_m_wqmsoilattributes_1_0__test_1() throws Exception { runKeyValue(); }
    @Test public void  wqm02_m_wqmsoilattributes_1_0__bug_1() throws Exception { runKeyValue(); }
    @Test public void  wqm02_m_wqmsoilattributes_1_0__bug_2() throws Exception { runKeyValue(); }
    
    @Test public void  wqm03_m_pestprodlist_1_0__ser_1() throws Exception { runKeyValue(); }
    
    @Test public void  wqm04_m_pestlosspot_1_0__ser_1() throws Exception { runKeyValue(); }
    @Test public void  wqm04_m_pestlosspot_1_0__bug_1() throws Exception { runKeyValue(); }
    @Test public void  wqm04_m_pestlosspot_1_0__test_1() throws Exception { runKeyValue(); }
    @Test public void  wqm04_m_pestlosspot_1_0__test1() throws Exception { runKeyValue(); }
    @Test public void  wqm04_m_pestlosspot_1_0__test_2() throws Exception { runKeyValue(); }
    
    @Test public void  wqm05_m_nutrient_slp_1_0__moderate() throws Exception { runKeyValue(); }
    @Test public void  wqm05_m_nutrient_slp_1_0__simple_1() throws Exception { runKeyValue(); }
    @Test public void  wqm05_m_nutrient_slp_1_0__ser_1() throws Exception { runKeyValue(); }
    @Test public void  wqm05_m_nutrient_slp_1_0__test2() throws Exception { runKeyValue(); }
    @Test public void  wqm05_m_nutrient_slp_1_0__test3() throws Exception { runKeyValue(); }
    @Test public void  wqm05_m_nutrient_slp_1_0__test4() throws Exception { runKeyValue(); }
    
    @Test public void  wqm06_m_scsednut_srp_1_0__test_1() throws Exception { runKeyValue(); }
    @Test public void  wqm06_m_scsednut_srp_1_0__ser_1() throws Exception { runKeyValue(); }
    @Test public void  wqm06_m_scsednut_srp_1_0__bug_1() throws Exception { runKeyValue(); }
    @Test public void  wqm06_m_scsednut_srp_1_0__test2() throws Exception { runKeyValue(); }
    @Test public void  wqm06_m_scsednut_srp_1_0__test3() throws Exception { runKeyValue(); }
    @Test public void  wqm06_m_scsednut_srp_1_0__test4() throws Exception { runKeyValue(); }
    
    @Test public void  wqm07_m_pesticide_slp_1_0__ser_1() throws Exception { runKeyValue(); }
    @Test public void  wqm07_m_pesticide_slp_1_0__test_1() throws Exception { runKeyValue(); }
    @Test public void  wqm07_m_pesticide_slp_1_0__test_2() throws Exception { runKeyValue(); }
    @Test public void  wqm07_m_pesticide_slp_1_0__test3() throws Exception { runKeyValue(); }
    @Test public void  wqm07_m_pesticide_slp_1_0__test4() throws Exception { runKeyValue(); }
    
    @Test public void  wqm08_m_pesticide_ssrp_1_0__ser_1() throws Exception { runKeyValue(); }
    @Test public void  wqm08_m_pesticide_ssrp_1_0__complex_1() throws Exception { runKeyValue(); }
    @Test public void  wqm08_m_pesticide_ssrp_1_0__simple_1() throws Exception { runKeyValue(); }
    @Test public void  wqm08_m_pesticide_ssrp_1_0__test1() throws Exception { runKeyValue(); }
    @Test public void  wqm08_m_pesticide_ssrp_1_0__test2() throws Exception { runKeyValue(); }
    @Test public void  wqm08_m_pesticide_ssrp_1_0__test3() throws Exception { runKeyValue(); }
    @Test public void  wqm08_m_pesticide_ssrp_1_0__test3_1() throws Exception { runKeyValue(); }
    
    @Test public void  wqm09_m_pesticide_sarp_1_0__ser_1() throws Exception { runKeyValue(); }
    @Test public void  wqm09_m_pesticide_sarp_1_0__test_1() throws Exception { runKeyValue(); }
    @Test public void  wqm09_m_pesticide_sarp_1_0__test1() throws Exception { runKeyValue(); }
    @Test public void  wqm09_m_pesticide_sarp_1_0__test2() throws Exception { runKeyValue(); }
    @Test public void  wqm09_m_pesticide_sarp_1_0__test3() throws Exception { runKeyValue(); }
    
    @Test public void  wqm10_m_soilpestlosspot_1_0__ser_1() throws Exception { runKeyValue(); }
    @Test public void  wqm10_m_soilpestlosspot_1_0__test_1() throws Exception { runKeyValue(); }
    @Test public void  wqm10_m_soilpestlosspot_1_0__test2() throws Exception { runKeyValue(); }
    
    @Test public void  wqm11_m_pest_hazrating_1_0__test_1() throws Exception { runKeyValue(); }
    @Test public void  wqm11_m_pest_hazrating_1_0__test1() throws Exception { runKeyValue(); }
    @Test public void  wqm11_m_pest_hazrating_1_0__test2() throws Exception { runKeyValue(); }
    @Test public void  wqm11_m_pest_hazrating_1_0__ser_1() throws Exception { runKeyValue(); }
    
    @Test public void  wqm12_m_rfactor_1_0__ser_1() throws Exception { runKeyValue(); }
    @Test public void  wqm12_m_rfactor_1_0__test_1() throws Exception { runKeyValue(); }
    @Test public void  wqm12_m_rfactor_1_0__test2() throws Exception { runKeyValue(); }
    @Test public void  wqm12_m_rfactor_1_0__test3() throws Exception { runKeyValue(); }
    @Test public void  wqm12_m_rfactor_1_0__test4() throws Exception { runKeyValue(); }
    @Test public void  wqm12_m_rfactor_1_0__test5() throws Exception { runKeyValue(); }
    @Test public void  wqm12_m_rfactor_1_0__test6() throws Exception { runKeyValue(); }
    @Test public void  wqm12_m_rfactor_1_0__test7() throws Exception { runKeyValue(); }
    @Test public void  wqm12_m_rfactor_1_0__test8() throws Exception { runKeyValue(); }
    @Test public void  wqm12_m_rfactor_1_0__test9() throws Exception { runKeyValue(); }
    
    @Test public void  wqm13_m_thresholdscores_1_0__ser_1() throws Exception { runKeyValue(); }
    @Test public void  wqm13_m_thresholdscores_1_0__test_1() throws Exception { runKeyValue(); }
    @Test public void  wqm13_m_thresholdscores_1_0__test2() throws Exception { runKeyValue(); }
    @Test public void  wqm13_m_thresholdscores_1_0__test3() throws Exception { runKeyValue(); }
    
    @Test public void  wqm14_m_nut_tech_scores_1_0__test_1() throws Exception { runKeyValue(); }
    @Test public void  wqm14_m_nut_tech_scores_1_0__ser_1() throws Exception { runKeyValue(); }
    @Test public void  wqm14_m_nut_tech_scores_1_0__bug_1() throws Exception { runKeyValue(); }
    @Test public void  wqm14_m_nut_tech_scores_1_0__bug_2() throws Exception { runKeyValue(); }
    
    @Test public void  wqm15_m_nut_pract_scores_1_0__test_1() throws Exception { runKeyValue(); }
    @Test public void  wqm15_m_nut_pract_scores_1_0__test2() throws Exception { runKeyValue(); }
    @Test public void  wqm15_m_nut_pract_scores_1_0__test1() throws Exception { runKeyValue(); }
    @Test public void  wqm15_m_nut_pract_scores_1_0__ser_1() throws Exception { runKeyValue(); }
    
    @Test public void  wqm16_m_nutappmgtscores_1_0__ser_1() throws Exception { runKeyValue(); }
    @Test public void  wqm16_m_nutappmgtscores_1_0__test2() throws Exception { runKeyValue(); }
    
    @Test public void  wqm17_m_pesticide_ipm_score_1_0__test_1() throws Exception { runKeyValue(); }
    @Test public void  wqm17_m_pesticide_ipm_score_1_0__test2() throws Exception { runKeyValue(); }
    @Test public void  wqm17_m_pesticide_ipm_score_1_0__ser_1() throws Exception { runKeyValue(); }
    
    @Test public void  wqm18_m_pest_techn_scores_1_0__test_1() throws Exception { runKeyValue(); }
    @Test public void  wqm18_m_pest_techn_scores_1_0__test2() throws Exception { runKeyValue(); }
    @Test public void  wqm18_m_pest_techn_scores_1_0__test3() throws Exception { runKeyValue(); }
    @Test public void  wqm18_m_pest_techn_scores_1_0__ser_1() throws Exception { runKeyValue(); }
    
    @Test public void  wqm19_m_pesticide_practice_score_1_0__test_1() throws Exception { runKeyValue(); }
    @Test public void  wqm19_m_pesticide_practice_score_1_0__test2() throws Exception { runKeyValue(); }
    @Test public void  wqm19_m_pesticide_practice_score_1_0__test3() throws Exception { runKeyValue(); }
    @Test public void  wqm19_m_pesticide_practice_score_1_0__test4() throws Exception { runKeyValue(); }
    @Test public void  wqm19_m_pesticide_practice_score_1_0__ser_1() throws Exception { runKeyValue(); }
    
    @Test public void  wqm20_m_wqmscorebar_1_0__test_1() throws Exception { runKeyValue(); }
    @Test public void  wqm20_m_wqmscorebar_1_0__test2() throws Exception { runKeyValue(); }
    @Test public void  wqm20_m_wqmscorebar_1_0__ser_1() throws Exception { runKeyValue(); }
    
    @Test public void  wqm21_m_nutrientslpsrp_1_0__ser_1() throws Exception { runKeyValue(); }
    @Test public void  wqm21_m_nutrientslpsrp_1_0__ser_2() throws Exception { runKeyValue(); }
    @Test public void  wqm21_m_nutrientslpsrp_1_0__NRCS_1() throws Exception { runKeyValue(); }
    @Test public void  wqm21_m_nutrientslpsrp_1_0__NRCS_2() throws Exception { runKeyValue(); }      
    @Test public void  wqm21_m_nutrientslpsrp_1_0__NRCS_3() throws Exception { runKeyValue(); } 
     
    @Test public void  wqm23_m_sednutpractscoresfull_1_0__test_1() throws Exception { runKeyValue(); }
    @Test public void  wqm23_m_sednutpractscoresfull_1_0__test2() throws Exception { runKeyValue(); }
    
    @Test public void  wqm24_m_ipmscoresfull_1_0_1__getfull() throws Exception { runKeyValue(); }
    @Test public void  wqm24_m_pestipmscoresfull_1_0__test_1() throws Exception { runKeyValue(); }
    @Test public void  wqm24_m_pestipmscoresfull_1_0__test2() throws Exception { runKeyValue(); }
    
    @Test public void  wqm25_m_pestmigtechsfull_1_0__test_1() throws Exception { runKeyValue(); }
    // .. more here
}