package com.googlecode.objectify.util;

import com.google.cloud.datastore.Key;
import org.junit.jupiter.api.Test;

import static com.google.common.truth.Truth.assertThat;

class KeyFormatTest {
	@Test
	void parsesAndFormatsOldStyleGAEKey() throws Exception {
		final String urlsafeKey = "agxzfm1haWxmb29nYWVyKAsSDE9yZ2FuaXphdGlvbiIKc3RyZWFrLmNvbQwLEgRVc2VyGJneWww";

		final Key key = KeyFormat.INSTANCE.parseOldStyleAppEngineKey(urlsafeKey);
		final String restringified = KeyFormat.INSTANCE.formatOldStyleAppEngineKey(key);

		assertThat(restringified).isEqualTo(urlsafeKey);
	}
}
@@ -252,16 +252,68 @@
 ption %7B%0A
+%09%09// Both of these get converted to the second form%0A
 %09%09final 
@@ -329,16 +329,17 @@
 lsafeKey
+1
  = %22agxz
@@ -411,16 +411,128 @@
 JneWww%22;
+%0A%09%09final String urlsafeKey2 = %22agxzfm1haWxmb29nYWVyKAsSDE9yZ2FuaXphdGlvbiIKc3RyZWFrLmNvbQwLEgRVc2VyGJneWwyiAQA%22;
 %0A%0A%09%09fina
@@ -594,24 +594,25 @@
 y(urlsafeKey
+1
 );%0A%09%09final S
@@ -685,16 +685,231 @@
 y(key);%0A
+%09%09assertThat(restringified).isEqualTo(urlsafeKey2);%0A%0A%09%09final Key key2 = KeyFormat.INSTANCE.parseOldStyleAppEngineKey(urlsafeKey2);%0A%09%09final String restringified2 = KeyFormat.INSTANCE.formatOldStyleAppEngineKey(key2);
 %0A%09%09asser
@@ -919,32 +919,33 @@
 at(restringified
+2
 ).isEqualTo(urls
@@ -950,15 +950,16 @@
 lsafeKey
+2
 );%0A%09%7D%0A%7D

Fix KeyFormatTest after new encoding changes