|
| 1 | +package com.researchspace.chemistry; |
| 2 | + |
| 3 | +import static org.junit.Assert.assertEquals; |
| 4 | + |
| 5 | +import com.researchspace.model.ChemSearchedItem; |
| 6 | +import com.researchspace.model.RSChemElement; |
| 7 | +import com.researchspace.model.User; |
| 8 | +import com.researchspace.model.record.RSForm; |
| 9 | +import com.researchspace.model.record.StructuredDocument; |
| 10 | +import com.researchspace.service.RSChemElementManager; |
| 11 | +import com.researchspace.service.RecordManager; |
| 12 | +import com.researchspace.testutils.RealTransactionSpringTestBase; |
| 13 | +import java.util.List; |
| 14 | +import org.junit.Ignore; |
| 15 | +import org.junit.Test; |
| 16 | +import org.springframework.beans.factory.annotation.Autowired; |
| 17 | +import org.springframework.test.context.TestPropertySource; |
| 18 | + |
| 19 | +@Ignore( |
| 20 | + "Requires chemistry service to run. See" |
| 21 | + + " https://documentation.researchspace.com/article/1jbygguzoa") |
| 22 | +@TestPropertySource( |
| 23 | + properties = {"chemistry.service.url=http://localhost:8090", "chemistry.provider=indigo"}) |
| 24 | +public class ChemistryDocumentCopyIT extends RealTransactionSpringTestBase { |
| 25 | + |
| 26 | + @Autowired RecordManager recordManager; |
| 27 | + |
| 28 | + @Autowired RSChemElementManager chemElementManager; |
| 29 | + |
| 30 | + @Test |
| 31 | + public void testCopiedDocumentsAreChemistrySearchable() throws Exception { |
| 32 | + User user = createInitAndLoginAnyUser(); |
| 33 | + RSForm form = createAnyForm(user); |
| 34 | + |
| 35 | + // create doc with chemical structure |
| 36 | + StructuredDocument doc = createDocumentInFolder(user.getRootFolder(), form, user); |
| 37 | + RSChemElement chem = addChemStructureToField(doc.getFields().get(0), user); |
| 38 | + |
| 39 | + // confirm 1 search result when searching for the chemical structure |
| 40 | + List<ChemSearchedItem> searchHits = |
| 41 | + chemElementManager.search(chem.getSmilesString(), "EXACT", 1000, user); |
| 42 | + assertEquals(1, searchHits.size()); |
| 43 | + |
| 44 | + // copy the doc |
| 45 | + recordManager.copy(doc.getId(), "copy", user, user.getRootFolder().getId()); |
| 46 | + |
| 47 | + // confirm 2 search results |
| 48 | + List<ChemSearchedItem> searchHitsAfterCopy = |
| 49 | + chemElementManager.search(chem.getSmilesString(), "EXACT", 1000, user); |
| 50 | + assertEquals(2, searchHitsAfterCopy.size()); |
| 51 | + } |
| 52 | +} |
0 commit comments