@Test
public void testCreateExtension() {

    final String extensionId = "4";
    final ExtensionRestrictionEntity restrictionEntity = new ExtensionRestrictionEntity();
    restrictionEntity.setId(UUID.randomUUID().toString());
    restrictionEntity.setExtensionId(extensionId);
    restrictionEntity.setRequiredPermission("read filesystem");
    restrictionEntity.setExplanation("Reads filesystem");
    final ExtensionProvidedServiceApiEntity serviceApiEntity = new ExtensionProvidedServiceApiEntity();
    serviceApiEntity.setId(UUID.randomUUID().toString());
    serviceApiEntity.setExtensionId(extensionId);
    serviceApiEntity.setClassName("com.foo.FooService");
    serviceApiEntity.setGroupId("com.foo");
    serviceApiEntity.setArtifactId("foo-nar");
    serviceApiEntity.setVersion("1.0.0");
    final ExtensionEntity extension = new ExtensionEntity();
    extension.setId(extensionId);
    extension.setBundleVersionId("eb1-v1");
    extension.setName("com.example.FooBarProcessor");
    extension.setDisplayName("FooBarProcessor");
    extension.setExtensionType(ExtensionType.PROCESSOR);
    extension.setTags(new HashSet<>(Arrays.asList("tag1", "tag2")));
    extension.setProvidedServiceApis(Collections.singleton(serviceApiEntity));
    extension.setRestrictions(Collections.singleton(restrictionEntity));
    extension.setContent("{ \"name\" : \"org.apache.nifi.ExampleProcessor\", \"type\" : \"PROCESSOR\" }");
    extension.setAdditionalDetails("DETAILS");
    metadataService.createExtension(extension);
    final ExtensionEntity retrievedExtension = metadataService.getExtensionById(extension.getId());
    assertEquals(extension.getId(), retrievedExtension.getId());
    assertEquals(extension.getBundleVersionId(), retrievedExtension.getBundleVersionId());
    assertEquals(extension.getName(), retrievedExtension.getName());
    assertEquals(extension.getDisplayName(), retrievedExtension.getDisplayName());
    assertEquals(extension.getExtensionType(), retrievedExtension.getExtensionType());
    assertEquals(extension.getContent(), retrievedExtension.getContent());
}