Skip to content

Commit 5752f77

Browse files
authored
fix(healthcare): don't store DICOM instance before each DICOMweb test (GoogleCloudPlatform#9292)
* fix(healthcare): don't store DICOM instance before each DICOMweb test * fix lint issues and remove @SuppressWarnings on method name because it's now technically valid
1 parent 61c9d9e commit 5752f77

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

healthcare/v1/src/test/java/snippets/healthcare/DicomWebTests.java

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,13 @@ public class DicomWebTests {
5656
private static String dicomStoreName;
5757
private static String datasetName;
5858

59-
// The studyUid is not assigned by the server and is part of the metadata of dcmFile.
59+
// The studyUid is not assigned by the server and is part of the metadata of
60+
// dcmFile.
6061
private static String studyId = "2.25.330012077234033941963257891139480825153";
6162
private static String seriesId = "2.25.143186483950719304925806365081717734297";
6263
private static String instanceId = "2.25.195151962645072062560826889007364152748";
63-
private static String dicomWebInstancePath =
64-
String.format("studies/%s/series/%s/instances/%s", studyId, seriesId, instanceId);
64+
private static String dicomWebInstancePath = String.format("studies/%s/series/%s/instances/%s",
65+
studyId, seriesId, instanceId);
6566
private static String dicomWebRenderedPath = dicomWebInstancePath + "/rendered";
6667

6768
private static String instanceOutput = "instance.dcm";
@@ -88,8 +89,8 @@ public static void checkRequirements() {
8889
@BeforeClass
8990
public static void setUp() throws IOException {
9091
String datasetId = "dataset-" + UUID.randomUUID().toString().replaceAll("-", "_");
91-
datasetName =
92-
String.format("projects/%s/locations/%s/datasets/%s", PROJECT_ID, REGION_ID, datasetId);
92+
datasetName = String.format("projects/%s/locations/%s/datasets/%s",
93+
PROJECT_ID, REGION_ID, datasetId);
9394
DatasetCreate.datasetCreate(PROJECT_ID, REGION_ID, datasetId);
9495

9596
String dicomStoreId = "dicom-" + UUID.randomUUID().toString().replaceAll("-", "_");
@@ -108,9 +109,6 @@ public void beforeTest() throws IOException, URISyntaxException {
108109
bout = new ByteArrayOutputStream();
109110
System.setOut(new PrintStream(bout));
110111

111-
// Store DICOM instance before each test so it is always available.
112-
DicomWebStoreInstance.dicomWebStoreInstance(dicomStoreName, "src/test/resources/jpeg_text.dcm");
113-
114112
bout = new ByteArrayOutputStream();
115113
System.setOut(new PrintStream(bout));
116114
}
@@ -122,29 +120,29 @@ public void tearDown() {
122120
}
123121

124122
@Test
125-
public void test_DicomWebStoreInstance() throws Exception {
123+
public void testA_DicomWebStoreInstance() throws Exception {
126124
DicomWebStoreInstance.dicomWebStoreInstance(dicomStoreName, "src/test/resources/jpeg_text.dcm");
127125

128126
String output = bout.toString();
129127
assertThat(output, containsString("DICOM instance stored:"));
130128
}
131129

132130
@Test
133-
public void test_DicomWebSearchInstances() throws Exception {
131+
public void testB_DicomWebSearchInstances() throws Exception {
134132
DicomWebSearchForInstances.dicomWebSearchForInstances(dicomStoreName);
135133
String output = bout.toString();
136134
assertThat(output, containsString("Dicom store instances found:"));
137135
}
138136

139137
@Test
140-
public void test_DicomWebSearchStudies() throws Exception {
138+
public void testC_DicomWebSearchStudies() throws Exception {
141139
DicomWebSearchStudies.dicomWebSearchStudies(dicomStoreName);
142140
String output = bout.toString();
143141
assertThat(output, containsString("Studies found:"));
144142
}
145143

146144
@Test
147-
public void test_DicomWebRetrieveStudy() throws Exception {
145+
public void testD_DicomWebRetrieveStudy() throws Exception {
148146
DicomWebRetrieveStudy.dicomWebRetrieveStudy(dicomStoreName, studyId);
149147

150148
outputFile = new File(studyOutput);
@@ -155,7 +153,7 @@ public void test_DicomWebRetrieveStudy() throws Exception {
155153
}
156154

157155
@Test
158-
public void test_DicomWebRetrieveInstance() throws Exception {
156+
public void testE_DicomWebRetrieveInstance() throws Exception {
159157
DicomWebRetrieveInstance.dicomWebRetrieveInstance(dicomStoreName, dicomWebInstancePath);
160158

161159
outputFile = new File(instanceOutput);
@@ -166,7 +164,7 @@ public void test_DicomWebRetrieveInstance() throws Exception {
166164
}
167165

168166
@Test
169-
public void test_DicomWebRetrieveRendered() throws Exception {
167+
public void testF_DicomWebRetrieveRendered() throws Exception {
170168
DicomWebRetrieveRendered.dicomWebRetrieveRendered(dicomStoreName, dicomWebRenderedPath);
171169

172170
outputFile = new File(renderedOutput);
@@ -180,8 +178,7 @@ public void test_DicomWebRetrieveRendered() throws Exception {
180178
// Test order is NAME_ASCENDING, so ensure that we delete the DICOM study
181179
// last, otherwise it might run before DicomWebRetrieve methods
182180
// (see https://github.com/GoogleCloudPlatform/java-docs-samples/issues/3845).
183-
@SuppressWarnings("checkstyle:MethodName")
184-
public void z_test_DicomWebDeleteStudy() throws IOException {
181+
public void testZ_DicomWebDeleteStudy() throws IOException {
185182
DicomWebDeleteStudy.dicomWebDeleteStudy(dicomStoreName, studyId);
186183

187184
String output = bout.toString();

0 commit comments

Comments
 (0)