content: /*
   * This file was automatically generated by UTestGen and EvoSuite
   * Mon Feb 12 22:28:54 GMT 2024
   */
  
  package com.lts.caloriecount.data.budget;
  
  import org.junit.jupiter.api.Test;
  import static org.junit.jupiter.api.Assertions.*;
  import org.junit.jupiter.api.Timeout;
  import java.util.concurrent.TimeUnit;
  import static org.evosuite.runtime.EvoAssertions.*;
  import com.lts.caloriecount.data.Adjustment;
  import com.lts.caloriecount.data.SimpleSerialization;
  import com.lts.caloriecount.data.budget.Budget;
  import com.lts.caloriecount.data.budget.TimeOfDay;
  import com.lts.xml.simple.SimpleElement;
  import org.evosuite.runtime.EvoRunner;
  import org.evosuite.runtime.EvoRunnerParameters;
  import org.evosuite.runtime.System;
  import org.junit.runner.RunWith;
  
  @RunWith(EvoRunner.class)
  @EvoRunnerParameters(
      mockJVMNonDeterminism = true,
      useVFS = true,
      useVNET = true,
      resetStaticState = true,
      separateClassLoader = true)
  public class Budget_ESTest extends Budget_ESTest_scaffolding {
  
    @Test
    @Timeout(value = 4000, unit = TimeUnit.MILLISECONDS)
    public void testInitializeBudget() throws Throwable {
      // Given a new budget
      Budget budget = new Budget();
  
      // When the budget is initialized
      budget.initialize();
  
      // Then the interval should be set to 0
      assertEquals(0L, budget.getInterval());
    }
  
    @Test
    @Timeout(value = 4000, unit = TimeUnit.MILLISECONDS)
    public void testGetStartOfDayShouldReturnNullWhenBudgetIsEmpty() throws Throwable {
      // Set up the test fixture
      Budget budget = new Budget();
  
      // Execute the behavior under test
      TimeOfDay startOfDay = budget.getStartOfDay();
  
      // Verify the results
      assertEquals("00:00", startOfDay.toString());
    }
  
    @Test
    @Timeout(value = 4000, unit = TimeUnit.MILLISECONDS)
    public void testGetStartOfDayWhenIdIs7ReturnsCorrectValue() throws Throwable {
      // Create a new Budget and set its start of day to a specific value (id=7)
      Budget budget = new Budget();
      TimeOfDay arg0 = new TimeOfDay();
      arg0.setId(7);
      budget.setStartOfDay(arg0);
  
      // Get the start of day for the budget and assert that it is equal to the value set above (id=7)
      TimeOfDay startOfDay = budget.getStartOfDay();
      assertEquals(7, startOfDay.getId());
    }
  
    @Test
    @Timeout(value = 4000, unit = TimeUnit.MILLISECONDS)
    public void testGetAndSetStartOfDay() throws Throwable {
      Budget budget = new Budget();
      TimeOfDay startOfDay = new TimeOfDay((-318), (-1431655765)); // Create a new instance of TimeOfDay with the specified ID
      startOfDay.setId((-318)); // Set the ID of the start of day to -318
      budget.setStartOfDay(startOfDay); // Set the start of day for the budget
      TimeOfDay actualStartOfDay = budget.getStartOfDay(); // Get the actual start of day for the budget
      assertEquals((-318), actualStartOfDay.getId()); // Assert that the ID of the actual start of day is -318
    }
  
    @Test
    @Timeout(value = 4000, unit = TimeUnit.MILLISECONDS)
    public void testSetStartOfDaySetsCorrectly() throws Throwable {
      // Test that the setStartOfDay method correctly sets the start of day
      Budget budget = new Budget();
      TimeOfDay arg0 = new TimeOfDay(-318, -1431655765);
      budget.setStartOfDay(arg0);
      assertEquals(0, budget.getStartOfDay().getId());
    }
  
    @Test
    @Timeout(value = 4000, unit = TimeUnit.MILLISECONDS)
    public void testMarkEndOfDayAsDirtyAndSetStartOfDayToSameValue() throws Throwable {
      // Set up a new Budget object and get its end-of-day TimeOfDay object
      Budget budget = new Budget();
      TimeOfDay endOfDay = budget.getEndOfDay();
  
      // Mark the end-of-day TimeOfDay as dirty
      endOfDay.setDirty(true);
  
      // Set the start-of-day TimeOfDay to be the same as the end-of-day TimeOfDay
      budget.setStartOfDay(endOfDay);
  
      // Get the start-of-day TimeOfDay object and check its ID
      TimeOfDay startOfDay = budget.getStartOfDay();
      assertEquals(0, startOfDay.getId());
    }
  
    @Test
    @Timeout(value = 4000, unit = TimeUnit.MILLISECONDS)
    public void testGetEndOfDayWithNullBudget() throws Throwable {
      // Given: A budget with a null end of day time
      Budget budget = new Budget();
      budget.setEndOfDay(null);
  
      // When: The end of day time is retrieved from the budget
      TimeOfDay endOfDay = budget.getEndOfDay();
  
      // Then: The end of day time should be null
      assertNull(endOfDay);
    }
  
    @Test
    @Timeout(value = 4000, unit = TimeUnit.MILLISECONDS)
    public void testSetEndOfDayUpdatesBudgetObject() throws Throwable {
      // Given a Budget object with an initial value of -567 for end of day
      Budget budget = new Budget();
      TimeOfDay arg0 = new TimeOfDay((-567), (-567));
  
      // When the setEndOfDay method is called with a new TimeOfDay object
      budget.setEndOfDay(arg0);
  
      // Then the end of day value for the Budget object should be updated to match the input
      assertEquals(-567, budget.getEndOfDay().getHour());
    }
  
    @Test
    @Timeout(value = 4000, unit = TimeUnit.MILLISECONDS)
    public void testGetCaloriesPerHour() throws Throwable {
      Budget budget = new Budget();
      budget.setCaloriesPerHour(1000.0); // Set the calories per hour to 1000.0
      double expectedCaloriesPerHour = 1000.0; // Expected calories per hour is 1000.0
      assertEquals(expectedCaloriesPerHour, budget.getCaloriesPerHour(), 0.01);
    }
  
    @Test
    @Timeout(value = 4000, unit = TimeUnit.MILLISECONDS)
    public void testGetNegativeCaloriesPerHour() throws Throwable {
      // Create a new budget instance with negative calories per hour
      Budget budget = new Budget();
      budget.setCaloriesPerHour(-1.0);
  
      // Get the calories per hour from the budget
      double caloriesPerHour = budget.getCaloriesPerHour();
  
      // Assert that the calories per hour is negative and within 0.01 of -1.0
      assertEquals(-1.0, caloriesPerHour, 0.01);
    }
  
    @Test
    @Timeout(value = 4000, unit = TimeUnit.MILLISECONDS)
    public void testPopulateFromElementEmptyBudget() throws Throwable {
      // Create a new budget and an empty element to populate it with
      Budget budget = new Budget();
      SimpleElement arg0 = new SimpleElement();
  
      // Populate the budget from the element
      budget.populateFromElement(arg0);
  
      // Check that the calories per hour are 0.0, and that the dirty flag is false
      assertEquals(0.0, budget.getCaloriesPerHour(), 0.01);
      assertFalse(budget.getDirty());
    }
  
    @Test
    @Timeout(value = 4000, unit = TimeUnit.MILLISECONDS)
    public void testCreateBudgetAndSetAttributes() throws Throwable {
      // Create a new Budget object
      Budget budget = new Budget();
  
      // Set the end of day for the budget to -1L
      TimeOfDay endOfDay = budget.getEndOfDay();
      endOfDay.setTime((-1L));
  
      // Set the calories per hour for the budget to -2625.5868
      budget.setCaloriesPerHour((-2625.5868));
  
      // Get the daily amount for the budget
      int dailyAmount = budget.getDailyAmount();
  
      // Assert that the calories per hour is -2625.5868 with a tolerance of 0.01
      assertEquals((-2625.5868), budget.getCaloriesPerHour(), 0.01);
  
      // Assert that the daily amount is -62970
      assertEquals((-62970), dailyAmount);
    }
  
    @Test
    @Timeout(value = 4000, unit = TimeUnit.MILLISECONDS)
    public void testDeserializationWithNullStartOfDay() throws Throwable {
      // Given a budget object with null start of day
      Budget budget = new Budget();
      budget.setStartOfDay(null);
  
      // When the object is deserialized
      budget.postDeserialize();
  
      // Then the daily amount should be set to 0
      assertEquals(0, budget.getDailyAmount());
    }
  
    @Test
    @Timeout(value = 4000, unit = TimeUnit.MILLISECONDS)
    public void testGetIntervalInitializedToZero() throws Throwable {
      // Given: A newly initialized budget with an interval of 0
      Budget budget = new Budget();
  
      // When: The interval is retrieved
      long interval = budget.getInterval();
  
      // Then: The interval should be 0
      assertEquals(0L, interval);
    }
  
    @Test
    @Timeout(value = 4000, unit = TimeUnit.MILLISECONDS)
    public void testGetInterval() throws Throwable {
      // Given: a Budget object with an interval set to 1234567890L
      Budget budget = new Budget();
      budget.setInterval(1234567890L);
  
      // When: the getInterval() method is called on the Budget object
      long interval = budget.getInterval();
  
      // Then: the returned interval should be 1234567890L
      assertEquals(1234567890L, interval);
    }
  
    @Test
    @Timeout(value = 4000, unit = TimeUnit.MILLISECONDS)
    public void testGetEndOfDayWhenStartOfDayIsMinus557Minutes() throws Throwable {
      // Given a Budget object with a start of day set to -557 minutes
      Budget budget = new Budget();
      TimeOfDay startOfDay = budget.getStartOfDay();
      startOfDay.setId(-557);
  
      // When the end of day is retrieved
      TimeOfDay endOfDay = budget.getEndOfDay();
  
      // Then the minute of the end of day should be 0
      assertEquals(0, endOfDay.getMinute());
    }
  
    @Test
    @Timeout(value = 4000, unit = TimeUnit.MILLISECONDS)
    public void testGetCaloriesPerHourWithZeroBudget() throws Throwable {
      // Given: A budget object
      Budget budget = new Budget();
  
      // When: The calories per hour is requested
      double caloriesPerHour = budget.getCaloriesPerHour();
  
      // Then: The calculated calories per hour should be 0
      assertEquals(0.0, caloriesPerHour, 0.01);
    }
  
    @Test
    @Timeout(value = 4000, unit = TimeUnit.MILLISECONDS)
    public void testDeserializationWithNullEndOfDay() throws Throwable {
      // Given: A new Budget object is created
      Budget budget = new Budget();
  
      // When: The end of day time is set to null and the post deserialize method is called
      budget.setEndOfDay(null);
      budget.postDeserialize();
  
      // Then: The calories per hour should be equal to 0.0, with a tolerance of 0.01
      assertEquals(0.0, budget.getCaloriesPerHour(), 0.01);
    }
  
    @Test
    @Timeout(value = 4000, unit = TimeUnit.MILLISECONDS)
    public void testSerializationAndDeserialization() throws Throwable {
      // Given a Budget object with default values
      Budget budget = new Budget();
  
      // When the object is serialized to an XML element
      SimpleElement element = budget.createSerializationElement();
  
      // Then the element should have the correct name and attributes
      assertEquals("budget", element.getName());
  
      // When the element is deserialized back into a Budget object
      budget.populateFromElement(element);
  
      // Then the Budget object should have the correct values
      assertEquals(0L, budget.getInterval());
      assertEquals(0.0, budget.getCaloriesPerHour(), 0.01);
      assertFalse(budget.getDirty());
    }
  
    @Test
    @Timeout(value = 4000, unit = TimeUnit.MILLISECONDS)
    public void testBudgetCaloriesPerHour() throws Throwable {
      // Given a Budget object with a caloriesPerHour value of 1107.01677051
      Budget budget = new Budget();
      budget.setCaloriesPerHour(1107.01677051);
  
      // When the current time is set to 24 hours (86,400,000L)
      System.setCurrentTimeMillis(864000000L);
  
      // Then the budgetUpToNow value should be 0
      int budgetUpToNow = budget.getBudgetUpToNow();
      assertEquals(1107.01677051, budget.getCaloriesPerHour(), 0.01);
      assertEquals(11992, budgetUpToNow);
    }
  
    @Test
    @Timeout(value = 4000, unit = TimeUnit.MILLISECONDS)
    public void testGetBudgetUpToNowWithSetCaloriesPerHour() throws Throwable {
      // Given a Budget object with a calories per hour set to 2000.0
      Budget budget = new Budget();
      budget.setCaloriesPerHour(2000.0);
  
      // When we get the budget up to now
      int budgetUpToNow = budget.getBudgetUpToNow();
  
      // Then the calories per hour is 2000.0 and the budget up to now is 40700
      assertEquals(2000.0, budget.getCaloriesPerHour(), 0.01);
      assertEquals(21666, budgetUpToNow);
    }
  
    @Test
    @Timeout(value = 4000, unit = TimeUnit.MILLISECONDS)
    public void testGetSerializationNameReturnsBudget() throws Throwable {
      // Given a budget object
      Budget budget = new Budget();
  
      // When we call getSerializationName on the budget object
      String serializationName = budget.getSerializationName();
  
      // Then the serialization name should be "budget"
      assertEquals("budget", serializationName);
    }
  
    @Test
    @Timeout(value = 4000, unit = TimeUnit.MILLISECONDS)
    public void testCopyFromThrowsClassCastException() throws Throwable {
      // Given: a budget object and a TimeOfDay object
      Budget budget = new Budget();
      TimeOfDay arg0 = new TimeOfDay();
  
      // When: copying the contents of the TimeOfDay object into the budget object
      try {
        budget.copyFrom(arg0);
      } catch (ClassCastException e) {
        // Then: an exception is thrown, as the TimeOfDay object cannot be cast to a Budget object
        verifyException("com.lts.caloriecount.data.budget.Budget", e);
      }
    }
  
    @Test
    @Timeout(value = 4000, unit = TimeUnit.MILLISECONDS)
    public void testGetBudgetUpToNowInitialValue() throws Throwable {
      // Given: A new Budget object is created and the budget up to now is initialized
      Budget budget = new Budget();
      int budgetUpToNow = budget.getBudgetUpToNow();
  
      // When: The budget up to now is retrieved
      assertEquals(0, budgetUpToNow);
    }
  
    @Test
    @Timeout(value = 4000, unit = TimeUnit.MILLISECONDS)
    public void testGetDailyAmountInitialValue() throws Throwable {
      // Given a new Budget object is created
      Budget budget = new Budget();
  
      // When the getDailyAmount method is called
      int dailyAmount = budget.getDailyAmount();
  
      // Then the initial value of 0 is returned
      assertEquals(0, dailyAmount);
    }
  
    @Test
    @Timeout(value = 4000, unit = TimeUnit.MILLISECONDS)
    public void testReplaceWithMethod() throws Throwable {
      // This test is checking the behavior of the replaceWith() method on a Budget object
      // It is creating an instance of the Budget class and passing it to the method as an argument
      Budget budget = new Budget();
      budget.replaceWith(budget);
  
      // The assertEquals() method is used to check if the result of the replaceWith() method is equal
      // to 0.0, with a tolerance of 0.01
      assertEquals(0.0, budget.getCaloriesPerHour(), 0.01);
    }
  
    @Test
    @Timeout(value = 4000, unit = TimeUnit.MILLISECONDS)
    public void testSerializeAndDeserializeBudget() throws Throwable {
      // Given a Budget object with default values
      Budget budget = new Budget();
  
      // When the object is serialized and deserialized
      SimpleElement arg0 = budget.createSerializationElement();
      budget.populateFromElement(arg0);
  
      // Then the resulting Budget object should have the same values as the original
      assertEquals("budget", arg0.getName());
      assertFalse(budget.getDirty());
      assertEquals(0.0, budget.getCaloriesPerHour(), 0.01);
    }
  
    @Test
    @Timeout(value = 4000, unit = TimeUnit.MILLISECONDS)
    public void testSerializeToWithNullInput() throws Throwable {
      // Given: A Budget object with a null input
      Budget budget = new Budget();
  
      // When: The serializeTo method is called with a null input
      try {
        budget.serializeTo((SimpleElement) null);
  
        // Then: An exception should be thrown
        fail("Expecting exception: NullPointerException");
  
      } catch (NullPointerException e) {
        // Verify that the correct exception is thrown
        verifyException("com.lts.caloriecount.data.budget.Budget", e);
      }
    }
  
    @Test
    @Timeout(value = 4000, unit = TimeUnit.MILLISECONDS)
    public void testDeserializeFromWithoutComments() throws Throwable {
      // No Comments were added
      Budget budget = new Budget();
      Adjustment adjustment = new Adjustment();
      SimpleElement arg0 = adjustment.createSerializationElement();
      budget.deserializeFrom(arg0);
      assertFalse(budget.getDirty());
      assertEquals(0.0, budget.getCaloriesPerHour(), 0.01);
    }
  }
  