private SearchMapping createSearchMapping() {
    SearchMapping mapping = new SearchMapping();

    mapping
        .entity(ProgrammaticConfiguredValue.class)
        .indexed()
        .property("id", ElementType.FIELD)
        .documentId()
        .name("id")
        .property("value", ElementType.FIELD)
        .field()
        .store(Store.YES)
        .indexNullAs("@null@");
    return mapping;
  }
 @Test
 public void documentIdNotOverriden() {
   SearchMapping mapping = new SearchMapping();
   mapping
       .entity(Book.class)
       .indexed()
       .property("title", ElementType.FIELD)
       .documentId()
       .property("text", ElementType.FIELD)
       .field();
   ManualConfiguration cfg =
       new ManualConfiguration()
           .addProperty("hibernate.search.default.directory_provider", "ram")
           .setProgrammaticMapping(mapping)
           // .setIdProvidedImplicit( false ) //Test it's the default
           .addClass(Book.class);
   storeBooksViaProvidedId(cfg, "title", true);
 }
  @Produces
  @ApplicationScoped
  @Default
  public EmbeddedCacheManager defaultEmbeddedCacheConfiguration() {
    if (manager == null) {
      GlobalConfiguration glob =
          new GlobalConfigurationBuilder()
              .globalJmxStatistics()
              .allowDuplicateDomains(true)
              .enable() // This
              // method enables the jmx statistics of the global
              // configuration and allows for duplicate JMX domains
              .build();

      SearchMapping mapping = new SearchMapping();
      mapping
          .entity(Task.class)
          .indexed()
          .providedId()
          .property("title", ElementType.METHOD)
          .field();

      Properties properties = new Properties();
      properties.put(org.hibernate.search.Environment.MODEL_MAPPING, mapping);
      properties.put("default.directory_provider", "ram");

      Configuration loc =
          new ConfigurationBuilder()
              .jmxStatistics()
              .enable() // Enable JMX statistics
              .eviction()
              .strategy(EvictionStrategy.NONE) // Do not evic objects
              .transaction()
              .transactionMode(TransactionMode.TRANSACTIONAL)
              .lockingMode(LockingMode.OPTIMISTIC)
              .indexing()
              .enable()
              .indexLocalOnly(false)
              .withProperties(properties)
              .build();
      manager = new DefaultCacheManager(glob, loc, true);
    }
    return manager;
  }
 @Test
 public void usingConfigurationTypeOverride() {
   SearchMapping mapping = new SearchMapping();
   mapping
       .entity(Book.class)
       .indexed()
       // Entity missing both @DocumentId and @ProvidedId:
       .property("title", ElementType.FIELD)
       .field()
       .property("text", ElementType.FIELD)
       .field();
   ManualConfiguration cfg =
       new ManualConfiguration()
           .addProperty("hibernate.search.default.directory_provider", "ram")
           .setProgrammaticMapping(mapping)
           .setIdProvidedImplicit(true)
           .addClass(Book.class);
   storeBooksViaProvidedId(cfg, ProvidedId.defaultFieldName, false);
 }
 @Test
 public void exceptionThrownWhenNotEnabled() {
   SearchMapping mapping = new SearchMapping();
   mapping
       .entity(Book.class)
       .indexed()
       // Entity missing both @DocumentId and @ProvidedId:
       .property("title", ElementType.FIELD)
       .field()
       .property("text", ElementType.FIELD)
       .field();
   ManualConfiguration cfg =
       new ManualConfiguration()
           .addProperty("hibernate.search.default.directory_provider", "ram")
           .setProgrammaticMapping(mapping)
           .addClass(Book.class);
   exceptions.expect(SearchException.class);
   exceptions.expectMessage("No document id in: " + Book.class.getName());
   storeBooksViaProvidedId(cfg, ProvidedId.defaultFieldName, false);
 }
 @Test
 public void usingDefaultSettings() {
   SearchMapping mapping = new SearchMapping();
   mapping
       .entity(Book.class)
       .indexed()
       .providedId()
       .name("myID")
       // Entity missing both @DocumentId and @ProvidedId:
       .property("title", ElementType.FIELD)
       .field()
       .property("text", ElementType.FIELD)
       .field();
   ManualConfiguration cfg =
       new ManualConfiguration()
           .addProperty("hibernate.search.default.directory_provider", "ram")
           .setProgrammaticMapping(mapping)
           // .setIdProvidedImplicit( false ) //Test it's the default
           .addClass(Book.class);
   storeBooksViaProvidedId(cfg, "myID", false);
 }