<commit_before>package com.artemis.managers;

import java.util.UUID;

import org.junit.Assert;
import org.junit.Test;

import com.artemis.Entity;
import com.artemis.MundaneWireException;
import com.artemis.World;

public class UuidEntityManagerTest {
	
	@Test(expected=MundaneWireException.class)
	public void throw_exception_missing_uuid_manager() {
		World world = new World();
		world.initialize();
		
		Entity entity = world.createEntity();
		entity.addToWorld();
		
		Assert.assertNotNull(entity.getUuid());
	}
	
	@Test
	public void uuid_assigned() {
		World world = new World();
		world.setManager(new UuidEntityManager());
		world.initialize();
		
		Entity entity = world.createEntity();
		entity.addToWorld();
		
		Assert.assertNotNull(entity.getUuid());
		UUID uuid1 = entity.getUuid();
		world.deleteEntity(entity);
		
		world.process();
		world.process();
		
		entity = world.createEntity();
		entity.addToWorld();
		
		Assert.assertNotNull(entity.getUuid());
		UUID uuid2 = entity.getUuid();

		Assert.assertNotEquals(uuid1, uuid2);
	}
	
	@Test
	public void explicit_uuids() {
		World world = new World();
		world.setManager(new UuidEntityManager());
		world.initialize();
		
		UUID[] uuids = new UUID[3];
		uuids[0] = UUID.randomUUID();
		uuids[1] = UUID.randomUUID();
		uuids[2] = UUID.randomUUID();
		
		Entity e1 = world.createEntity(uuids[0]);
		e1.addToWorld();
		Entity e2 = world.createEntity(uuids[1]);
		e2.addToWorld();
		Entity e3 = world.createEntity(uuids[2]);
		e3.addToWorld();
		
		Assert.assertEquals(uuids[0], e1.getUuid());
		Assert.assertEquals(uuids[1], e2.getUuid());
		Assert.assertEquals(uuids[2], e3.getUuid());
	}
}<commit_msg>Another UuidEntityManager test<commit_after>package com.artemis.managers;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;

import java.util.UUID;

import org.junit.Assert;
import org.junit.Test;

import com.artemis.Entity;
import com.artemis.MundaneWireException;
import com.artemis.World;

public class UuidEntityManagerTest {
	
	@Test(expected=MundaneWireException.class)
	public void throw_exception_missing_uuid_manager() {
		World world = new World();
		world.initialize();
		
		Entity entity = world.createEntity();
		entity.addToWorld();
		
		Assert.assertNotNull(entity.getUuid());
	}
	
	@Test
	public void uuid_assigned() {
		World world = new World();
		world.setManager(new UuidEntityManager());
		world.initialize();
		
		Entity entity = world.createEntity();
		entity.addToWorld();
		
		assertNotNull(entity.getUuid());
		UUID uuid1 = entity.getUuid();
		world.deleteEntity(entity);
		
		world.process();
		world.process();
		
		entity = world.createEntity();
		entity.addToWorld();
		
		assertNotNull(entity.getUuid());
		UUID uuid2 = entity.getUuid();

		assertNotEquals(uuid1, uuid2);
	}
	
	@Test
	public void uuid_updates_work() {
		World world = new World();
		UuidEntityManager uuidManager = world.setManager(new UuidEntityManager());
		world.initialize();
		
		Entity entity = world.createEntity();
		entity.addToWorld();
		
		UUID uuid0 = entity.getUuid();
		Assert.assertNotNull(uuid0);
		
		UUID uuid1 = UUID.randomUUID();
		
		assertEquals(uuid0, entity.getUuid());
		entity.setUuid(uuid1);
		assertEquals(uuid1, entity.getUuid());
		
		
		assertNotEquals(uuid0, uuid1);
		assertNull(uuidManager.getEntity(uuid0));
		assertEquals(entity, uuidManager.getEntity(uuid1));
	}
	
	@Test
	public void explicit_uuids() {
		World world = new World();
		world.setManager(new UuidEntityManager());
		world.initialize();
		
		UUID[] uuids = new UUID[3];
		uuids[0] = UUID.randomUUID();
		uuids[1] = UUID.randomUUID();
		uuids[2] = UUID.randomUUID();
		
		Entity e1 = world.createEntity(uuids[0]);
		e1.addToWorld();
		Entity e2 = world.createEntity(uuids[1]);
		e2.addToWorld();
		Entity e3 = world.createEntity(uuids[2]);
		e3.addToWorld();
		
		assertEquals(uuids[0], e1.getUuid());
		assertEquals(uuids[1], e2.getUuid());
		assertEquals(uuids[2], e3.getUuid());
	}
}
{'fraction_non_alphanumeric': 0.14208721215090642, 'fraction_numerical': 0.013718765311121999, 'mean_word_length': 4.6551246537396125, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4231052', 'n_tokens_mistral': 1535, 'n_tokens_neox': 1372, 'n_words': 250}