Volver al índice
src/main/java/ar/com/companeros/identity/ProfileCompatibilityTests.java
package ar.com.companeros.identity;
import ar.com.companeros.Companeros;
import java.util.*;
import net.minecraft.nbt.*;
import net.minecraft.gametest.framework.*;
import net.minecraftforge.gametest.*;
@GameTestHolder(Companeros.ID)
@PrefixGameTestTemplate(false)
public final class ProfileCompatibilityTests {
@GameTest(template = "empty")
public void offlineProfilesMatchMinecraftAndRemapOnlyTheirReferences(GameTestHelper helper) {
UUID old = UUID.fromString("1e4eb943-6bc8-4813-9c91-cbdc7d972eca"), next = PlayerProfileIds.offline("Neon"), human = UUID.randomUUID();
helper.assertTrue(next.equals(UUID.fromString("68e79ab5-69dd-350b-a1d3-73b2f9b89fb1"))
&& PlayerProfileIds.offline("Xenon").equals(UUID.fromString("4f72ea90-a7d1-3d81-9b97-8f06df3ea18d")), "UUID offline estándar por nombre");
CompoundTag root = new CompoundTag(); root.putUUID("Agent", old); root.putUUID("Human", human);
root.putString("Source", "AGENT:" + old); root.putLong("OwnerUUIDMost", old.getMostSignificantBits()); root.putLong("OwnerUUIDLeast", old.getLeastSignificantBits());
root.putInt("Iron", 37); root.putLong("OccurredAtUtc", 12345);
ListTag list = new ListTag(); list.add(StringTag.valueOf(old.toString())); root.put("Relations", list);
helper.assertTrue(ProfileUuidRemapper.remap(root, Map.of(old, next)) && root.getUUID("Agent").equals(next)
&& root.getUUID("Human").equals(human) && root.getString("Source").equals("AGENT:" + next)
&& root.getLong("OwnerUUIDMost") == next.getMostSignificantBits()
&& root.getList("Relations", Tag.TAG_STRING).getString(0).equals(next.toString())
&& root.getInt("Iron") == 37 && root.getLong("OccurredAtUtc") == 12345, "Referencias migran sin cambiar otros jugadores, recursos o fechas");
helper.assertTrue(!ProfileUuidRemapper.remap(root, Map.of(old, next)), "Migración idempotente");
helper.succeed();
}
@GameTest(template = "empty")
public void researcherRolePersistsAndDelegatesProduction(GameTestHelper helper) {
UUID researcher = UUID.randomUUID(), other = UUID.randomUUID(); AgentRoles roles = new AgentRoles();
roles.assign(researcher, AgentRoles.Role.INVESTIGADOR);
AgentRoles restored = AgentRoles.load(roles.save(new CompoundTag()));
helper.assertTrue(restored.role(researcher) == AgentRoles.Role.INVESTIGADOR
&& restored.role(other) == AgentRoles.Role.GENERALISTA
&& restored.allows(researcher, "research_recipe") && restored.allows(researcher, "eat")
&& restored.allows(researcher, "attack") && !restored.allows(researcher, "mine_block")
&& !restored.allows(researcher, "place_block"), "Rol individual persistente; investigación y supervivencia sin proyectos de producción");
helper.succeed();
}
}