DefaultSolrDocumentCollectionManager implements SolrDocumentCollectionManager { @Override public DocumentEntity insert(DocumentEntity entity) { Objects.requireNonNull(entity, "entity is required"); try { solrClient.add(getDocument(entity)); commit(); } catch (SolrServerException | IOException e) { throw new SolrException("Error to insert/update a information", e); } return entity; } DefaultSolrDocumentCollectionManager(HttpSolrClient solrClient); @Override DocumentEntity insert(DocumentEntity entity); @Override DocumentEntity insert(DocumentEntity entity, Duration ttl); @Override Iterable<DocumentEntity> insert(Iterable<DocumentEntity> entities); @Override Iterable<DocumentEntity> insert(Iterable<DocumentEntity> entities, Duration ttl); @Override DocumentEntity update(DocumentEntity entity); @Override Iterable<DocumentEntity> update(Iterable<DocumentEntity> entities); @Override void delete(DocumentDeleteQuery query); @Override Stream<DocumentEntity> select(DocumentQuery query); @Override long count(String documentCollection); @Override void close(); @Override List<DocumentEntity> solr(String query); @Override List<DocumentEntity> solr(String query, Map<String, ? extends Object> params);  }
@Test public void shouldInsert() { DocumentEntity entity = getEntity(); DocumentEntity documentEntity = entityManager.insert(entity); assertTrue(documentEntity.getDocuments().stream().map(Document::getName).anyMatch(s -> s.equals(ID))); }
@Test public void shouldThrowExceptionWhenInsertWithTTL() { assertThrows(UnsupportedOperationException.class, () -> entityManager.insert(getEntity(), Duration.ofSeconds(10))); }
@Test public void shouldReturnErrorWhenSaveSubDocument() { DocumentEntity entity = getEntity(); entity.add(Document.of("phones", Document.of("mobile", "1231231"))); Assertions.assertThrows(SolrException.class, () -> entityManager.insert(entity)); }
@Test public void shouldSaveSubDocument2() { DocumentEntity entity = getEntity(); entity.add(Document.of("phones", asList(Document.of("mobile", "1231231"), Document.of("mobile2", "1231231")))); Assertions.assertThrows(SolrException.class, () -> entityManager.insert(entity)); }
@Test public void shouldRetrieveListSubdocumentList() { Assertions.assertThrows(SolrException.class, () -> entityManager.insert(createSubdocumentList())); }