diff --git a/monkey/monkey_island/cc/repository/file_simulation_repository.py b/monkey/monkey_island/cc/repository/file_simulation_repository.py index fed7ce0eb..021a7083e 100644 --- a/monkey/monkey_island/cc/repository/file_simulation_repository.py +++ b/monkey/monkey_island/cc/repository/file_simulation_repository.py @@ -14,13 +14,6 @@ class FileSimulationRepository(ISimulationRepository): self._file_repository = file_repository self._simulation_schema = SimulationSchema() - def save_simulation(self, simulation: Simulation): - simulation_json = self._simulation_schema.dumps(simulation) - - self._file_repository.save_file( - SIMULATION_STATE_FILE_NAME, io.BytesIO(simulation_json.encode()) - ) - def get_simulation(self) -> Simulation: try: with self._file_repository.open_file(SIMULATION_STATE_FILE_NAME) as f: @@ -32,6 +25,13 @@ class FileSimulationRepository(ISimulationRepository): except Exception as err: raise RetrievalError(f"Error retrieving the simulation state: {err}") + def save_simulation(self, simulation: Simulation): + simulation_json = self._simulation_schema.dumps(simulation) + + self._file_repository.save_file( + SIMULATION_STATE_FILE_NAME, io.BytesIO(simulation_json.encode()) + ) + def get_mode(self) -> IslandModeEnum: return self.get_simulation().mode diff --git a/monkey/monkey_island/cc/repository/i_simulation_repository.py b/monkey/monkey_island/cc/repository/i_simulation_repository.py index 880d456fd..816b691e1 100644 --- a/monkey/monkey_island/cc/repository/i_simulation_repository.py +++ b/monkey/monkey_island/cc/repository/i_simulation_repository.py @@ -5,16 +5,6 @@ from monkey_island.cc.services.mode.mode_enum import IslandModeEnum class ISimulationRepository(ABC): - @abstractmethod - def save_simulation(self, simulation: Simulation): - """ - Save the simulation state - - :param simulation: The simulation state - :raises StorageError: If the simulation states could not be saved - """ - pass - @abstractmethod def get_simulation(self) -> Simulation: """ @@ -25,6 +15,16 @@ class ISimulationRepository(ABC): pass + @abstractmethod + def save_simulation(self, simulation: Simulation): + """ + Save the simulation state + + :param simulation: The simulation state + :raises StorageError: If the simulation states could not be saved + """ + pass + @abstractmethod def get_mode(self) -> IslandModeEnum: """