private TextDependencyExtractor getTextDependencyExtractor() { return new TextDependencyExtractorImpl(env.getPlatform().convertDbObjectName()); }
@Before public void setup() { when(tableChangeType.getName()).thenReturn(ChangeType.TABLE_STR); when(platform.getChangeType(ChangeType.TABLE_STR)).thenReturn(tableChangeType); when(platform.convertDbObjectName()).thenReturn(Functions.getStringPassThru()); }
@Override protected String getRestrictedValue(Environment env) { return env.getPlatform().getName(); } }
private ImmutableMap<ChangeType, Pattern> initPatternMap(Platform platform) { MutableMap<String, Pattern> params = Maps.mutable.<String, Pattern>with() .withKeyValue(ChangeType.SP_STR, Pattern.compile("(?i)create\\s+proc(?:edure)?\\s+(\\w+)", Pattern.DOTALL)) .withKeyValue(ChangeType.FUNCTION_STR, Pattern.compile("(?i)create\\s+func(?:tion)?\\s+(\\w+)", Pattern.DOTALL)) .withKeyValue(ChangeType.VIEW_STR, Pattern.compile("(?i)create\\s+view\\s+(\\w+)", Pattern.DOTALL)) .withKeyValue(ChangeType.SEQUENCE_STR, Pattern.compile("(?i)create\\s+seq(?:uence)?\\s+(\\w+)", Pattern.DOTALL)) .withKeyValue(ChangeType.TABLE_STR, Pattern.compile("(?i)create\\s+table\\s+(\\w+)", Pattern.DOTALL)) .withKeyValue(ChangeType.DEFAULT_STR, Pattern.compile("(?i)create\\s+default\\s+(\\w+)", Pattern.DOTALL)) .withKeyValue(ChangeType.RULE_STR, Pattern.compile("(?i)create\\s+rule\\s+(\\w+)", Pattern.DOTALL)) .withKeyValue(ChangeType.USERTYPE_STR, Pattern.compile("(?i)^\\s*sp_addtype\\s+", Pattern.DOTALL)) .withKeyValue(ChangeType.INDEX_STR, Pattern.compile("(?i)create\\s+(?:unique\\s+)?(?:\\w+\\s+)?index\\s+\\w+\\s+on\\s+(\\w+)", Pattern.DOTALL)); MutableMap<ChangeType, Pattern> patternMap = Maps.mutable.<ChangeType, Pattern>with(); for (String changeTypeName : params.keysView()) { if (platform.hasChangeType(changeTypeName)) { ChangeType changeType = platform.getChangeType(changeTypeName); patternMap.put(changeType, params.get(changeTypeName)); } } return patternMap.toImmutable(); }
DeployExecutionDao.DEPLOY_EXECUTION_TABLE_NAME, DeployExecutionDao.DEPLOY_EXECUTION_ATTRIBUTE_TABLE_NAME ).collect(platform.convertDbObjectName())); ObjectTypeAndNamePredicateBuilder objectExclusionPredicateBuilder = platform.getObjectExclusionPredicateBuilder() .add(coreTablesToExclude.toImmutable()); if (excludeObjects != null) { params.put("platform", platform.getName()); params.put("schemas", schemas); params.put("jdbcUrl", jdbcUrl);
@Test public void test() { ChangeType changeType = mock(ChangeType.class); when(changeType.getName()).thenReturn("type"); Platform platform = mock(Platform.class); when(platform.getChangeType(Mockito.anyString())).thenReturn(changeType); MongoDbEnvironment env = mock(MongoDbEnvironment.class); when(env.getPhysicalSchema("mydb")).thenReturn(new PhysicalSchema("mydb")); when(env.getPhysicalSchemas()).thenReturn(Sets.immutable.of(new PhysicalSchema("mydb"))); MongoDbChangeAuditDao changeAuditDao = new MongoDbChangeAuditDao(mongoClient, env, platform, "test"); DeployExecutionImpl exec = new DeployExecutionImpl("requester", "executor", "schema", "1.0.0", new Timestamp(new Date().getTime()), false, false, "1.0.0", "reason", Sets.immutable.<DeployExecutionAttribute>empty()); exec.setId(1L); Change change = new ChangeIncremental(changeType, "mydb", "obj1", "c1", 0, "hash", "content"); changeAuditDao.insertNewChange(change, exec); assertEquals(1, changeAuditDao.getDeployedChanges().size()); } }
for (ChangeType changeType : systemDbPlatform.getChangeTypes()) { ImmutableList<String> excludedNames = iterListString(excludesConfig, changeType.getName().toLowerCase()); if (excludedNames.notEmpty()) { return new Schema(schemaName, systemDbPlatform.getObjectExclusionPredicateBuilder().add(excludedNameMap.toImmutable()), readOnly);
public DeployerAppContext getAppContextBuilder() { DeployerAppContext deployerAppContext; try { if (appContextBuilderClass != null) { deployerAppContext = this.appContextBuilderClass.newInstance(); } else { deployerAppContext = this.platform.getAppContextBuilderClass().newInstance(); } } catch (InstantiationException e) { throw new DeployerRuntimeException(e); } catch (IllegalAccessException e) { throw new DeployerRuntimeException(e); } deployerAppContext.setEnvironment(this); if (defaultUserId != null && defaultPassword != null) { deployerAppContext.setCredential(new Credential(defaultUserId, defaultPassword)); } return deployerAppContext; }
protected FileSourceParams getFileSourceParams(boolean baseline) { return FileSourceParams.newBuilder() .setSchemaNames(env.getSchemaNames()) .setFiles(env.getSourceDirs()) .setBaseline(baseline) .setAcceptedExtensions(env.getAcceptedExtensions()) .setChangeTypes(env.getPlatform().getChangeTypes()) .setDefaultSourceEncoding(env.getSourceEncoding()) .setLegacyDirectoryStructureEnabled(env.isLegacyDirectoryStructureEnabled()) .build(); }
public ImmutableSet<String> getAcceptedExtensions() { if (acceptedExtensions != null && acceptedExtensions.notEmpty()) { return acceptedExtensions; } return getPlatform().getAcceptedExtensions(); }
DeployExecutionDao.DEPLOY_EXECUTION_TABLE_NAME, DeployExecutionDao.DEPLOY_EXECUTION_ATTRIBUTE_TABLE_NAME ).collect(platform.convertDbObjectName())); ObjectTypeAndNamePredicateBuilder objectExclusionPredicateBuilder = platform.getObjectExclusionPredicateBuilder() .add(coreTablesToExclude.toImmutable()); if (excludeObjects != null) { params.put("platform", platform.getName()); params.put("schemas", schemas); params.put("jdbcUrl", jdbcUrl);
private ImmutableMap<ChangeType, Pattern> initPatternMap(Platform platform) { MutableMap<String, Pattern> params = Maps.mutable.<String, Pattern>with() .withKeyValue(ChangeType.SP_STR, Pattern.compile("(?i)create\\s+proc(?:edure)?\\s+(\\w+)", Pattern.DOTALL)) .withKeyValue(ChangeType.FUNCTION_STR, Pattern.compile("(?i)create\\s+func(?:tion)?\\s+(\\w+)", Pattern.DOTALL)) .withKeyValue(ChangeType.VIEW_STR, Pattern.compile("(?i)create\\s+view\\s+(\\w+)", Pattern.DOTALL)) .withKeyValue(ChangeType.SEQUENCE_STR, Pattern.compile("(?i)create\\s+seq(?:uence)?\\s+(\\w+)", Pattern.DOTALL)) .withKeyValue(ChangeType.TABLE_STR, Pattern.compile("(?i)create\\s+table\\s+(\\w+)", Pattern.DOTALL)) .withKeyValue(ChangeType.DEFAULT_STR, Pattern.compile("(?i)create\\s+default\\s+(\\w+)", Pattern.DOTALL)) .withKeyValue(ChangeType.RULE_STR, Pattern.compile("(?i)create\\s+rule\\s+(\\w+)", Pattern.DOTALL)) .withKeyValue(ChangeType.USERTYPE_STR, Pattern.compile("(?i)^\\s*sp_addtype\\s+", Pattern.DOTALL)) .withKeyValue(ChangeType.INDEX_STR, Pattern.compile("(?i)create\\s+(?:unique\\s+)?(?:\\w+\\s+)?index\\s+\\w+\\s+on\\s+(\\w+)", Pattern.DOTALL)); MutableMap<ChangeType, Pattern> patternMap = Maps.mutable.<ChangeType, Pattern>with(); for (String changeTypeName : params.keysView()) { if (platform.hasChangeType(changeTypeName)) { ChangeType changeType = platform.getChangeType(changeTypeName); patternMap.put(changeType, params.get(changeTypeName)); } } return patternMap.toImmutable(); }
@Test public void test() { ChangeType changeType = mock(ChangeType.class); when(changeType.getName()).thenReturn("type"); Platform platform = mock(Platform.class); when(platform.getChangeType(Mockito.anyString())).thenReturn(changeType); MongoDbEnvironment env = mock(MongoDbEnvironment.class); when(env.getPhysicalSchema("mydb")).thenReturn(new PhysicalSchema("mydb")); when(env.getPhysicalSchemas()).thenReturn(Sets.immutable.of(new PhysicalSchema("mydb"))); MongoDbChangeAuditDao changeAuditDao = new MongoDbChangeAuditDao(mongoClient, env, platform, "test"); DeployExecutionImpl exec = new DeployExecutionImpl("requester", "executor", "schema", "1.0.0", new Timestamp(new Date().getTime()), false, false, "1.0.0", "reason", Sets.immutable.<DeployExecutionAttribute>empty()); exec.setId(1L); Change change = new ChangeIncremental(changeType, "mydb", "obj1", "c1", 0, "hash", "content"); changeAuditDao.insertNewChange(change, exec); assertEquals(1, changeAuditDao.getDeployedChanges().size()); } }
for (ChangeType changeType : systemDbPlatform.getChangeTypes()) { ImmutableList<String> excludedNames = iterListString(excludesConfig, changeType.getName().toLowerCase()); if (excludedNames.notEmpty()) { return new Schema(schemaName, systemDbPlatform.getObjectExclusionPredicateBuilder().add(excludedNameMap.toImmutable()), readOnly);
public DeployerAppContext getAppContextBuilder() { DeployerAppContext deployerAppContext; try { if (appContextBuilderClass != null) { deployerAppContext = this.appContextBuilderClass.newInstance(); } else { deployerAppContext = this.platform.getAppContextBuilderClass().newInstance(); } } catch (InstantiationException e) { throw new DeployerRuntimeException(e); } catch (IllegalAccessException e) { throw new DeployerRuntimeException(e); } deployerAppContext.setEnvironment(this); if (defaultUserId != null && defaultPassword != null) { deployerAppContext.setCredential(new Credential(defaultUserId, defaultPassword)); } return deployerAppContext; }
protected FileSourceParams getFileSourceParams(boolean baseline) { return FileSourceParams.newBuilder() .setSchemaNames(env.getSchemaNames()) .setFiles(env.getSourceDirs()) .setBaseline(baseline) .setAcceptedExtensions(env.getAcceptedExtensions()) .setChangeTypes(env.getPlatform().getChangeTypes()) .setDefaultSourceEncoding(env.getSourceEncoding()) .setLegacyDirectoryStructureEnabled(env.isLegacyDirectoryStructureEnabled()) .build(); }
public ImmutableSet<String> getAcceptedExtensions() { if (acceptedExtensions != null && acceptedExtensions.notEmpty()) { return acceptedExtensions; } return getPlatform().getAcceptedExtensions(); }
protected GraphEnricher graphEnricher() { return new GraphEnricherImpl(env.getPlatform().convertDbObjectName()); }
@Override protected String getRestrictedValue(Environment env) { return env.getPlatform().getName(); } }
private static DeployerAppContext getAppContextBuilder(Environment env, Credential credential) { DeployerAppContext deployerAppContext; try { deployerAppContext = env.getPlatform().getAppContextBuilderClass().newInstance(); } catch (InstantiationException e) { throw new DeployerRuntimeException(e); } catch (IllegalAccessException e) { throw new DeployerRuntimeException(e); } deployerAppContext.setEnvironment(env); if (credential == null) { credential = getDefaultCredential(env); } deployerAppContext.setCredential(credential); return deployerAppContext; }