@Test public void guessCredentialWithMoreThan4FieldsAndCharacters() throws Exception { DBCredential dbCredential = new DBCredential(); dbCredential.setName("APP.dev-int.secret.long.<key*"); DBCredential result = migrateService.guessCredentialProperties(dbCredential); Assert.assertEquals("dev-int", result.getSdlc()); Assert.assertEquals(null, result.getComponent()); Assert.assertEquals("secret.long.<key*", result.getShortKey()); }
public DBCredential guessCredentialProperties(DBCredential dbCredential) { Matcher threeFieldsMatcher = threeFieldsPattern.matcher(dbCredential.getName()); if (threeFieldsMatcher.matches()) { logger.info("Parsing " + dbCredential.getName()); String sdlc = threeFieldsMatcher.group(2); dbCredential.setSdlc(sdlc); } else{ try { String sdlc = dbCredential.getName().split("\\.")[1]; dbCredential.setSdlc(sdlc); } catch (Exception e) { logger.error("Error parsing key " + dbCredential.getName()); } } return dbCredential; }
MigrateService { public DBCredential guessCredentialProperties(DBCredential dbCredential) { Matcher threeFieldsMatcher = threeFieldsPattern.matcher(dbCredential.getName()); if (threeFieldsMatcher.matches()) { logger.info("Parsing " + dbCredential.getName()); String sdlc = threeFieldsMatcher.group(2); dbCredential.setSdlc(sdlc); } else{ try { String sdlc = dbCredential.getName().split("\\.")[1]; dbCredential.setSdlc(sdlc); } catch (Exception e) { logger.error("Error parsing key " + dbCredential.getName()); } } return dbCredential; } }
MigrateService { public DBCredential guessCredentialProperties(DBCredential dbCredential) { Matcher threeFieldsMatcher = threeFieldsPattern.matcher(dbCredential.getName()); if (threeFieldsMatcher.matches()) { logger.info("Parsing " + dbCredential.getName()); String sdlc = threeFieldsMatcher.group(2); dbCredential.setSdlc(sdlc); } else{ try { String sdlc = dbCredential.getName().split("\\.")[1]; dbCredential.setSdlc(sdlc); } catch (Exception e) { logger.error("Error parsing key " + dbCredential.getName()); } } return dbCredential; }  }
MigrateService { public DBCredential guessCredentialProperties(DBCredential dbCredential) { Matcher threeFieldsMatcher = threeFieldsPattern.matcher(dbCredential.getName()); if (threeFieldsMatcher.matches()) { logger.info("Parsing " + dbCredential.getName()); String sdlc = threeFieldsMatcher.group(2); dbCredential.setSdlc(sdlc); } else{ try { String sdlc = dbCredential.getName().split("\\.")[1]; dbCredential.setSdlc(sdlc); } catch (Exception e) { logger.error("Error parsing key " + dbCredential.getName()); } } return dbCredential; }  DBCredential migrateCredential(DBCredential dbCredential, FideliusService fideliusService); DBCredential guessCredentialProperties(DBCredential dbCredential); }
MigrateService { public DBCredential guessCredentialProperties(DBCredential dbCredential) { Matcher threeFieldsMatcher = threeFieldsPattern.matcher(dbCredential.getName()); if (threeFieldsMatcher.matches()) { logger.info("Parsing " + dbCredential.getName()); String sdlc = threeFieldsMatcher.group(2); dbCredential.setSdlc(sdlc); } else{ try { String sdlc = dbCredential.getName().split("\\.")[1]; dbCredential.setSdlc(sdlc); } catch (Exception e) { logger.error("Error parsing key " + dbCredential.getName()); } } return dbCredential; }  DBCredential migrateCredential(DBCredential dbCredential, FideliusService fideliusService); DBCredential guessCredentialProperties(DBCredential dbCredential);  }