+
+ @Bean
+ public A1Client getA1Client() {
+ PolicyTypes ricTypes = new PolicyTypes();
+ loadTypes(ricTypes);
+ A1Client client = new MockA1Client(ricTypes);
+ return client;
+ }
+
+ @Bean
+ public Policies getPolicies() {
+ return this.policies;
+ }
+
+ @Bean
+ public PolicyTypes getPolicyTypes() {
+ return this.policyTypes;
+ }
+
+ @Bean
+ public Rics getRics() {
+ return this.rics;
+ }
+
+ private static File[] getResourceFolderFiles(String folder) {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ URL url = loader.getResource(folder);
+ String path = url.getPath();
+ return new File(path).listFiles();
+ }
+
+ private static String readFile(File file) throws IOException {
+ return new String(Files.readAllBytes(file.toPath()));
+ }
+
+ private void loadTypes(PolicyTypes policyTypes) {
+ File[] files = getResourceFolderFiles("policy_types/");
+ for (File file : files) {
+ try {
+ String schema = readFile(file);
+ String typeName = title(schema);
+ PolicyType type = ImmutablePolicyType.builder().name(typeName).schema(schema).build();
+ policyTypes.put(type);
+ } catch (Exception e) {
+ System.out.println("Could not load json schema " + e);
+ }
+ }
+ }
+