@Test public void migrateCredentialWith4FieldsAndComponent() throws Exception { DBCredential dbCredential = new DBCredential(); dbCredential.setName("APP.component.dev.key"); doReturn("correct").when(fideliusService).getCredential("key", "APP", "dev", "component", tableName, "FideliusMigrateTask"); DBCredential result = migrateService.migrateCredential(dbCredential, fideliusService); Assert.assertEquals("dev", result.getSdlc()); Assert.assertEquals("component", result.getComponent()); }
public DBCredential migrateCredential(DBCredential dbCredential, FideliusService fideliusService) { this.fideliusService = fideliusService; Matcher threeFieldsMatcher = threeFieldsPattern.matcher(dbCredential.getName()); Matcher fourFieldsMatcher = fourFieldsPattern.matcher(dbCredential.getName()); Matcher extraFieldsMatcher = extraFieldsPattern.matcher(dbCredential.getName()); if (threeFieldsMatcher.matches()) { logger.info("3 Fields: " + dbCredential.getName()); try { String key = threeFieldsMatcher.group(3); String ags = threeFieldsMatcher.group(1); String sdlc = threeFieldsMatcher.group(2); migrate(ags, sdlc, null, key, dbCredential); } catch (Exception e) { logger.error("Error migrating " + dbCredential.getName()); } } if (fourFieldsMatcher.matches() && dbCredential.getSdlc() == null) { logger.info("4 Fields: " + dbCredential.getName()); migrate(fourFieldsMatcher, dbCredential); } if (extraFieldsMatcher.matches() && dbCredential.getSdlc() == null) { logger.info("More than 4 Fields: " + dbCredential.getName()); migrate(extraFieldsMatcher, dbCredential); } if(dbCredential.getSdlc() != null) logger.info("Successfully retrieved " + dbCredential.getName()); else { logger.error("Failed to migrate: " + dbCredential.getName()); } return dbCredential; }
MigrateService { public DBCredential migrateCredential(DBCredential dbCredential, FideliusService fideliusService) { this.fideliusService = fideliusService; Matcher threeFieldsMatcher = threeFieldsPattern.matcher(dbCredential.getName()); Matcher fourFieldsMatcher = fourFieldsPattern.matcher(dbCredential.getName()); Matcher extraFieldsMatcher = extraFieldsPattern.matcher(dbCredential.getName()); if (threeFieldsMatcher.matches()) { logger.info("3 Fields: " + dbCredential.getName()); try { String key = threeFieldsMatcher.group(3); String ags = threeFieldsMatcher.group(1); String sdlc = threeFieldsMatcher.group(2); migrate(ags, sdlc, null, key, dbCredential); } catch (Exception e) { logger.error("Error migrating " + dbCredential.getName()); } } if (fourFieldsMatcher.matches() && dbCredential.getSdlc() == null) { logger.info("4 Fields: " + dbCredential.getName()); migrate(fourFieldsMatcher, dbCredential); } if (extraFieldsMatcher.matches() && dbCredential.getSdlc() == null) { logger.info("More than 4 Fields: " + dbCredential.getName()); migrate(extraFieldsMatcher, dbCredential); } if(dbCredential.getSdlc() != null) logger.info("Successfully retrieved " + dbCredential.getName()); else { logger.error("Failed to migrate: " + dbCredential.getName()); } return dbCredential; } }
MigrateService { public DBCredential migrateCredential(DBCredential dbCredential, FideliusService fideliusService) { this.fideliusService = fideliusService; Matcher threeFieldsMatcher = threeFieldsPattern.matcher(dbCredential.getName()); Matcher fourFieldsMatcher = fourFieldsPattern.matcher(dbCredential.getName()); Matcher extraFieldsMatcher = extraFieldsPattern.matcher(dbCredential.getName()); if (threeFieldsMatcher.matches()) { logger.info("3 Fields: " + dbCredential.getName()); try { String key = threeFieldsMatcher.group(3); String ags = threeFieldsMatcher.group(1); String sdlc = threeFieldsMatcher.group(2); migrate(ags, sdlc, null, key, dbCredential); } catch (Exception e) { logger.error("Error migrating " + dbCredential.getName()); } } if (fourFieldsMatcher.matches() && dbCredential.getSdlc() == null) { logger.info("4 Fields: " + dbCredential.getName()); migrate(fourFieldsMatcher, dbCredential); } if (extraFieldsMatcher.matches() && dbCredential.getSdlc() == null) { logger.info("More than 4 Fields: " + dbCredential.getName()); migrate(extraFieldsMatcher, dbCredential); } if(dbCredential.getSdlc() != null) logger.info("Successfully retrieved " + dbCredential.getName()); else { logger.error("Failed to migrate: " + dbCredential.getName()); } return dbCredential; }  }
MigrateService { public DBCredential migrateCredential(DBCredential dbCredential, FideliusService fideliusService) { this.fideliusService = fideliusService; Matcher threeFieldsMatcher = threeFieldsPattern.matcher(dbCredential.getName()); Matcher fourFieldsMatcher = fourFieldsPattern.matcher(dbCredential.getName()); Matcher extraFieldsMatcher = extraFieldsPattern.matcher(dbCredential.getName()); if (threeFieldsMatcher.matches()) { logger.info("3 Fields: " + dbCredential.getName()); try { String key = threeFieldsMatcher.group(3); String ags = threeFieldsMatcher.group(1); String sdlc = threeFieldsMatcher.group(2); migrate(ags, sdlc, null, key, dbCredential); } catch (Exception e) { logger.error("Error migrating " + dbCredential.getName()); } } if (fourFieldsMatcher.matches() && dbCredential.getSdlc() == null) { logger.info("4 Fields: " + dbCredential.getName()); migrate(fourFieldsMatcher, dbCredential); } if (extraFieldsMatcher.matches() && dbCredential.getSdlc() == null) { logger.info("More than 4 Fields: " + dbCredential.getName()); migrate(extraFieldsMatcher, dbCredential); } if(dbCredential.getSdlc() != null) logger.info("Successfully retrieved " + dbCredential.getName()); else { logger.error("Failed to migrate: " + dbCredential.getName()); } return dbCredential; }  DBCredential migrateCredential(DBCredential dbCredential, FideliusService fideliusService); DBCredential guessCredentialProperties(DBCredential dbCredential); }
MigrateService { public DBCredential migrateCredential(DBCredential dbCredential, FideliusService fideliusService) { this.fideliusService = fideliusService; Matcher threeFieldsMatcher = threeFieldsPattern.matcher(dbCredential.getName()); Matcher fourFieldsMatcher = fourFieldsPattern.matcher(dbCredential.getName()); Matcher extraFieldsMatcher = extraFieldsPattern.matcher(dbCredential.getName()); if (threeFieldsMatcher.matches()) { logger.info("3 Fields: " + dbCredential.getName()); try { String key = threeFieldsMatcher.group(3); String ags = threeFieldsMatcher.group(1); String sdlc = threeFieldsMatcher.group(2); migrate(ags, sdlc, null, key, dbCredential); } catch (Exception e) { logger.error("Error migrating " + dbCredential.getName()); } } if (fourFieldsMatcher.matches() && dbCredential.getSdlc() == null) { logger.info("4 Fields: " + dbCredential.getName()); migrate(fourFieldsMatcher, dbCredential); } if (extraFieldsMatcher.matches() && dbCredential.getSdlc() == null) { logger.info("More than 4 Fields: " + dbCredential.getName()); migrate(extraFieldsMatcher, dbCredential); } if(dbCredential.getSdlc() != null) logger.info("Successfully retrieved " + dbCredential.getName()); else { logger.error("Failed to migrate: " + dbCredential.getName()); } return dbCredential; }  DBCredential migrateCredential(DBCredential dbCredential, FideliusService fideliusService); DBCredential guessCredentialProperties(DBCredential dbCredential);  }