/*                                                                      *\
**                    SICU Stress Measurement System                    **
**                      Project P04  |  C380 Team A                     **
**          EBME 380: Biomedical Engineering Design Experience          **
**                    Case Western Reserve University                   **
**                          2016 Fall Semester                          **
\*                                                                      */

package edu.cwru.sicu_sms.util;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.util.Properties;

import static org.junit.jupiter.api.Assertions.*;

/**
 * Test class for {@link PropertyOperator}.
 *
 * @since December 14, 2016
 * @author Ted Frohlich <ttf10@case.edu>
 * @author Abby Walker <amw138@case.edu>
 */
class PropertyOperatorTest {
    
    private static final String LOAD_FILE = "src/test/resources/util/TestProperties.properties";
    private static final String SAVE_FILE = "src/test/resources/util/TestProperties.properties";
    
    private Properties propertiesToTest;
    
    @BeforeEach
    void setUp() {
        propertiesToTest = new Properties();
        propertiesToTest.setProperty("key_string", "value_string");
        propertiesToTest.setProperty("key_int",    "380");
        propertiesToTest.setProperty("key_float",  "216.368");
    }
    
    @AfterEach
    void tearDown() {
        propertiesToTest.clear();
        propertiesToTest = null;
    }
    
    @Test
    void loadProperties() {
        Properties propertiesToLoad = PropertyOperator.loadProperties(LOAD_FILE);
        
        // TODO: needs to be implemented
        
        assert false;
    }
    
    @Test
    void saveProperties() {
        Properties propertiesToSave = propertiesToTest;
        propertiesToSave.setProperty("new_key", "new_value");
        
        boolean success = PropertyOperator.saveProperties(
                propertiesToSave, SAVE_FILE, "Test Properties - UPDATED");
        
        assert success;
    }
    
}
@@ -981,25 +981,25 @@
  String 
-LOAD_FILE
+PATH_ROOT
  = %22src/
@@ -1010,32 +1010,92 @@
 /resources/util/
+%22;%0A    private static final String LOAD_FILE = PATH_ROOT + %22
 TestProperties.p
@@ -1154,33 +1154,21 @@
 E = 
-%22src/test/resources/util/
+PATH_ROOT + %22
 Test
@@ -1627,16 +1627,61 @@
 = null;%0A
+        // TODO: restore original file state%0A
     %7D%0A  
@@ -1732,33 +1732,39 @@
      Properties 
-p
+loadedP
 ropertiesToLoad 
@@ -1760,14 +1760,8 @@
 ties
-ToLoad
  = P
@@ -1824,49 +1824,377 @@
     
-// TODO: needs to be implemented%0A
+assertEquals(propertiesToTest.size(), loadedProperties.size());%0A        %0A        loadedProperties.keySet().forEach(key -%3E %7B%0A            Object value = loadedProperties.get(key);%0A            System.out.println(key + %22=%22 + value);%0A            %0A            assert propertiesToTest.containsKey(key);%0A            Object expectedValue = propertiesToTest.get(key);%0A   
         
 %0A   
@@ -2181,33 +2181,38 @@
 ey);%0A           
-%0A
+ %0A    
         assert f
@@ -2213,14 +2213,48 @@
 sert
- false
+Equals(expectedValue, value);%0A        %7D)
 ;%0A  

Implement 'loadProperties' test method