2
2
3
3
import ca .uhn .fhir .jpa .binstore .DatabaseBinaryContentStorageSvcImpl ;
4
4
import ca .uhn .fhir .jpa .binstore .FilesystemBinaryStorageSvcImpl ;
5
+ import ca .uhn .fhir .jpa .binary .api .IBinaryStorageSvc ;
5
6
import ca .uhn .fhir .jpa .starter .AppProperties ;
6
7
import org .junit .jupiter .api .Test ;
7
8
import org .junit .jupiter .api .io .TempDir ;
8
- import org .springframework .beans .factory .ObjectProvider ;
9
9
10
10
import java .nio .file .Files ;
11
11
import java .nio .file .Path ;
12
- import java .util .function .Supplier ;
13
12
14
13
import static org .assertj .core .api .Assertions .assertThat ;
15
14
import static org .assertj .core .api .Assertions .assertThatThrownBy ;
@@ -27,7 +26,7 @@ private FhirServerConfigCommon newConfig() {
27
26
void defaultsToDatabaseImplementation () {
28
27
AppProperties props = new AppProperties ();
29
28
30
- Object svc = binaryStorageSvc (props );
29
+ IBinaryStorageSvc svc = binaryStorageSvc (props );
31
30
32
31
assertThat (svc ).isInstanceOf (DatabaseBinaryContentStorageSvcImpl .class );
33
32
}
@@ -83,39 +82,15 @@ void filesystemModeRequiresBaseDirectory() {
83
82
.hasMessageContaining ("binary_storage_filesystem_base_directory" );
84
83
}
85
84
86
- private Object binaryStorageSvc (AppProperties props ) {
85
+ private IBinaryStorageSvc binaryStorageSvc (AppProperties props ) {
87
86
FhirServerConfigCommon config = newConfig ();
88
- return config . binaryStorageSvc (
89
- props ,
90
- provider (() -> config . databaseBinaryStorageSvc ( props )),
91
- provider (() -> config .filesystemBinaryStorageSvc (props )) );
87
+ if ( props . getBinary_storage_mode () == AppProperties . BinaryStorageMode . FILESYSTEM ) {
88
+ return config . filesystemBinaryStorageSvc ( props );
89
+ }
90
+ return config .databaseBinaryStorageSvc (props );
92
91
}
93
92
94
93
private FilesystemBinaryStorageSvcImpl filesystemBinaryStorageSvc (AppProperties props ) {
95
94
return (FilesystemBinaryStorageSvcImpl ) binaryStorageSvc (props );
96
95
}
97
-
98
- private static <T > ObjectProvider <T > provider (Supplier <T > supplier ) {
99
- return new ObjectProvider <>() {
100
- @ Override
101
- public T getObject (Object ... args ) {
102
- return supplier .get ();
103
- }
104
-
105
- @ Override
106
- public T getObject () {
107
- return supplier .get ();
108
- }
109
-
110
- @ Override
111
- public T getIfAvailable () {
112
- return supplier .get ();
113
- }
114
-
115
- @ Override
116
- public T getIfUnique () {
117
- return supplier .get ();
118
- }
119
- };
120
- }
121
96
}
0 commit comments