import java.io.File;
import java.io.IOException;
+import java.nio.file.Files;
import java.util.Optional;
import net.pterodactylus.rhynodge.State;
import net.pterodactylus.rhynodge.states.StateManager.StateDirectory;
import com.fasterxml.jackson.annotation.JsonProperty;
-import com.google.common.io.Files;
import org.hamcrest.Matchers;
import org.jspecify.annotations.NonNull;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
-import static com.google.common.base.Charsets.UTF_8;
+import static java.util.Arrays.asList;
import static org.apache.log4j.Level.OFF;
import static org.apache.log4j.Logger.getLogger;
import static org.hamcrest.MatcherAssert.assertThat;
@Test
public void invalidJsonFileCanNotBeLoaded() throws IOException {
- Files.write("not json", new File(tempFolder, "test.last.json"), UTF_8);
+ Files.write(tempFolder.toPath().resolve("test.last.json"), asList("not json"));
Optional<State> restoredState = stateManager.loadLastState("test");
assertThat(restoredState.isPresent(), is(false));
}
@Test
public void jsonWithInvalidFieldsCanNotBeLoaded() throws IOException {
- Files.write("{\"not\":\"json\"}", new File(tempFolder, "test.last.json"), UTF_8);
+ Files.write(tempFolder.toPath().resolve("test.last.json"), asList("{\"not\":\"json\"}"));
Optional<State> restoredState = stateManager.loadLastState("test");
assertThat(restoredState.isPresent(), is(false));
}