001/* ***** BEGIN LICENSE BLOCK ***** 002 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 003 * 004 * The contents of this file are subject to the Mozilla Public License Version 005 * 1.1 (the "License"); you may not use this file except in compliance with 006 * the License. You may obtain a copy of the License at 007 * http://www.mozilla.org/MPL/ 008 * 009 * Software distributed under the License is distributed on an "AS IS" basis, 010 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 011 * for the specific language governing rights and limitations under the 012 * License. 013 * 014 * The Original Code is part of dcm4che, an implementation of DICOM(TM) in 015 * Java(TM), hosted at https://github.com/gunterze/dcm4che. 016 * 017 * The Initial Developer of the Original Code is 018 * Agfa Healthcare. 019 * Portions created by the Initial Developer are Copyright (C) 2011 020 * the Initial Developer. All Rights Reserved. 021 * 022 * Contributor(s): 023 * See @authors listed below 024 * 025 * Alternatively, the contents of this file may be used under the terms of 026 * either the GNU General Public License Version 2 or later (the "GPL"), or 027 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 028 * in which case the provisions of the GPL or the LGPL are applicable instead 029 * of those above. If you wish to allow use of your version of this file only 030 * under the terms of either the GPL or the LGPL, and not to allow others to 031 * use your version of this file under the terms of the MPL, indicate your 032 * decision by deleting the provisions above and replace them with the notice 033 * and other provisions required by the GPL or the LGPL. If you do not delete 034 * the provisions above, a recipient may use your version of this file under 035 * the terms of any one of the MPL, the GPL or the LGPL. 036 * 037 * ***** END LICENSE BLOCK ***** */ 038 039package org.dcm4che3.tool.dcmgen.test; 040 041import static org.junit.Assert.assertTrue; 042 043import java.io.File; 044import java.util.List; 045 046import org.dcm4che3.data.Attributes; 047import org.dcm4che3.tool.common.test.TestResult; 048import org.dcm4che3.tool.common.test.TestTool; 049import org.dcm4che3.tool.dcmgen.DcmGen; 050 051/** 052 * @author Hesham Elbadawi <bsdreko@gmail.com> 053 * 054 */ 055public class DcmGenTool implements TestTool { 056 057 private int instanceCount = 1; 058 059 private int seriesCount = 1; 060 061 private File outputDir; 062 063 private File seedFile; 064 065 private TestResult result; 066 067 public DcmGenTool(int instanceCount,int seriesCount, File outputDir, File seedFile) { 068 super(); 069 this.instanceCount = instanceCount; 070 this.seriesCount = seriesCount; 071 this.outputDir = outputDir; 072 this.seedFile = seedFile; 073 } 074 075 public void generateFiles(String testDescription, Attributes override) { 076 DcmGen generator = new DcmGen(); 077 generator.setInstanceCount(instanceCount); 078 generator.setSeriesCount(seriesCount); 079 generator.setOutputDir(outputDir); 080 generator.setSeedFile(seedFile); 081 List<String> results = generator.generateDICOM(override==null?new Attributes():override); 082 init(new DcmGenResult(results)); 083 assertTrue(results.size() >= 1); 084 } 085 086 public void generateFiles(String testDescription, Attributes override, File seed) { 087 DcmGen generator = new DcmGen(); 088 generator.setInstanceCount(instanceCount); 089 generator.setSeriesCount(seriesCount); 090 generator.setOutputDir(outputDir); 091 generator.setSeedFile(seed); 092 List<String> results = generator.generateDICOM(override==null?new Attributes():override); 093 init(new DcmGenResult(results)); 094 assertTrue(results.size() >= 1); 095 } 096 097 @Override 098 public void init(TestResult result) { 099 this.result = result; 100 } 101 102 @Override 103 public TestResult getResult() { 104 return this.result; 105 } 106 107 public int getInstanceCount() { 108 return instanceCount; 109 } 110 111 public int getSeriesCount() { 112 return seriesCount; 113 } 114 115 public File getOutputDir() { 116 return outputDir; 117 } 118 119 public File getSeedFile() { 120 return seedFile; 121 } 122 123}