public void testReagentRelationship() throws IOException { schemaUtil.truncateTables(); Reagent reagent = dataFactory.newInstance(SmallMoleculeReagent.class); ReagentAttachedFileType attachedFileType = new ReagentAttachedFileType("Application"); genericEntityDao.saveOrUpdateEntity(attachedFileType); AttachedFile attachedFile1 = reagent.createAttachedFile("filename1", attachedFileType, new LocalDate(), new ReaderInputStream(new StringReader("file contents 1"))); AttachedFile attachedFile2 = reagent.createAttachedFile("filename2", attachedFileType, new LocalDate(), "file contents 2"); genericEntityDao.saveOrUpdateEntity(reagent.getLibraryContentsVersion().getLibrary()); reagent = genericEntityDao.reloadEntity(reagent); AttachedFile attachedFile1b = genericEntityDao.findEntityById(AttachedFile.class, attachedFile1.getEntityId(), true, AttachedFile.reagent); AttachedFile attachedFile2b = genericEntityDao.findEntityById(AttachedFile.class, attachedFile2.getEntityId(), true, AttachedFile.reagent); assertEquals(reagent, attachedFile1b.getReagent()); assertEquals(reagent, attachedFile2b.getReagent()); }
@Test public void testLoadXmlProperties() throws InvalidPropertiesFormatException, IOException { Properties props = new Properties(); Reader reader = new StringReader("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<!DOCTYPE properties SYSTEM \"http://java.sun.com/dtd/properties.dtd\">\n" + "<properties>\n" + "<comment>Hi</comment>\n" + "<entry key=\"foo\">1</entry>\n" + "<entry key=\"fu\">baz</entry>\n" + "</properties>"); InputStream stream = new ReaderInputStream(reader ); props.loadFromXML(stream); assertEquals("1", props.get("foo")); }
public void testScreenRelationship() throws IOException { schemaUtil.truncateTables(); Screen screen = dataFactory.newInstance(Screen.class); ScreenAttachedFileType attachedFileType = new ScreenAttachedFileType("Application"); genericEntityDao.persistEntity(attachedFileType); screen.createAttachedFile("filename1", attachedFileType, new LocalDate(), new ReaderInputStream(new StringReader("file contents 1"))); screen.createAttachedFile("filename2", attachedFileType, new LocalDate(), "file contents 2"); screen = genericEntityDao.mergeEntity(screen); screen = genericEntityDao.reloadEntity(screen, true, Screen.attachedFiles.to(AttachedFile.screen)); for (AttachedFile attachedFile : screen.getAttachedFiles()) { assertEquals(screen, attachedFile.getScreen()); } }
public void testScreeningUserRelationship() throws IOException { schemaUtil.truncateTables(); ScreeningRoomUser user = dataFactory.newInstance(ScreeningRoomUser.class); UserAttachedFileType attachedFileType = new UserAttachedFileType("Application"); genericEntityDao.persistEntity(attachedFileType); user.createAttachedFile("filename1", attachedFileType, new LocalDate(), new ReaderInputStream(new StringReader("file contents 1"))); user.createAttachedFile("filename2", attachedFileType, new LocalDate(), "file contents 2"); user = genericEntityDao.mergeEntity(user); user = genericEntityDao.reloadEntity(user, true, ScreeningRoomUser.attachedFiles.to(AttachedFile.screeningRoomUser)); for (AttachedFile attachedFile : user.getAttachedFiles()) { assertEquals(user, attachedFile.getScreeningRoomUser()); } }
/** * Opens a stream to the content of the script. * * @return The content stream, not null */ @Override protected InputStream getScriptInputStream() { return new ReaderInputStream(new StringReader(scriptContent)); }