AtomicInteger inc = new AtomicInteger();
@Test
public void testExec() throws Exception {
long beforeCount = _categoryRepository.count();
final MetadataCategory category = _categoryRepository.findAll().get(0);
assertEquals(beforeCount, _categoryRepository.count());
Metadata entity = MetadataRepositoryTest.newMetadata(inc);
entity.getCategories().add(category);
entity = _MetadataRepository.save(entity);
ServiceContext context = createServiceContext();
loginAsAdmin(context);
remove.exec(category.getId());
assertEquals(beforeCount - 1, _categoryRepository.count());
assertEquals(1, _MetadataRepository.count());
entity = _MetadataRepository.findOne(entity.getId());
assertTrue(entity.getCategories().isEmpty());