@Test
public void testCategoryCreateAndRemove() {

    Set<UserFieldDescriptor> descriptors = new HashSet<>();
    FeedManagerUserFieldDescriptor descriptor1 = new FeedManagerUserFieldDescriptor();
    descriptor1.setSystemName("property1");
    descriptor1.setDisplayName("Property1");
    descriptor1.setDescription(" desc for property1");
    descriptor1.setOrder(1);
    descriptor1.setRequired(true);
    descriptors.add(descriptor1);
    FeedManagerUserFieldDescriptor descriptor2 = new FeedManagerUserFieldDescriptor();
    descriptor2.setSystemName("property2");
    descriptor2.setDisplayName("Property2");
    descriptor2.setDescription(" desc for property2");
    descriptor2.setOrder(2);
    descriptor2.setRequired(false);
    descriptors.add(descriptor2);
    metadataAccess.commit(() -> {
        categoryProvider.setUserFields(descriptors);
    }, MetadataAccess.ADMIN);
    Set<UserFieldDescriptor> feedManagerFieldDescriptors = metadataAccess.read(() -> {
        return transformFieldDescriptors(categoryProvider.getUserFields());
    }, MetadataAccess.ADMIN);
    Assert.assertTrue(feedManagerFieldDescriptors.size() == 2);
    //now try to delete the first one
    feedManagerFieldDescriptors.removeIf(descriptor -> descriptor.getOrder() == 1);
    Assert.assertTrue(feedManagerFieldDescriptors.size() == 1);
    metadataAccess.commit(() -> {
        categoryProvider.setUserFields(feedManagerFieldDescriptors);
    }, MetadataAccess.ADMIN);
    Set<UserFieldDescriptor> finalDescriptors = metadataAccess.read(() -> categoryProvider.getUserFields(), MetadataAccess.ADMIN);
    Assert.assertTrue(finalDescriptors.size() == 1);
}