org.eclipse.collections.impl.block.factory.Predicates Java Examples
The following examples show how to use
org.eclipse.collections.impl.block.factory.Predicates.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LookupPredicateBuilder.java From obevo with Apache License 2.0 | 6 votes |
public static Predicates<? super String> convert(ImmutableCollection<String> patterns) { if (patterns == null) { return Predicates.alwaysTrue(); } PartitionIterable<String> wildcardPartition = patterns.partition(Predicates.or(StringPredicates.contains("*"), StringPredicates.contains("%"))); RichIterable<String> wildcardPatterns = wildcardPartition.getSelected(); RichIterable<WildcardPatternIndex> wildcardPatternIndexes = wildcardPatterns.collect(new Function<String, WildcardPatternIndex>() { @Override public WildcardPatternIndex valueOf(String patternString) { return new WildcardPatternIndex(patternString); } }); RichIterable<String> lookupPatterns = wildcardPartition.getRejected(); LookupIndex lookupIndex = lookupPatterns.notEmpty() ? new LookupIndex(lookupPatterns.toSet().toImmutable()) : null; MutableList<Index> indexes = Lists.mutable.empty(); if (lookupIndex != null) { indexes.add(lookupIndex); } indexes.withAll(wildcardPatternIndexes); return Predicates.or(indexes); }
Example #2
Source File: IqLoadFileCreator.java From obevo with Apache License 2.0 | 6 votes |
IqLoadFileCreator(String tableName, MutableList<FieldToColumnMapping> fieldToColumnMappings, File iqLoadDir, String loadFilePrefix, IqLoadMode iqLoadMode, DataExtractor dataExtractor) { this.tableName = tableName; PartitionMutableList<FieldToColumnMapping> parsedMappings = fieldToColumnMappings.partition(Predicates.attributeIsNull(FieldToColumnMapping.defaultValue())); this.mappingsWithoutDefaults = parsedMappings.getSelected(); this.mappingsWithDefaults = parsedMappings.getRejected(); this.iqLoadDir = iqLoadDir; this.loadFilePrefix = loadFilePrefix; this.cub.register(new SybaseIqLoadFieldConverter(), String.class); this.iqLoadMode = iqLoadMode; this.dataExtractor = dataExtractor; this.fileToWrite = new File(this.getFilePath()); this.filePathToLoad = iqLoadMode.isConvertToWindowsFileSyntax() ? this.getFilePath().replace("\\", "\\\\") : this.getFilePath() .replace("\\", "/"); }
Example #3
Source File: BaselineValidatorMainTest.java From obevo with Apache License 2.0 | 6 votes |
@Test public void testBaselineMismatchScenario() { DbDeployerAppContext appContext = DbEnvironmentFactory.getInstance().readOneFromSourcePath("baselineutil/BaselineValidatorMain/uc1", "test") .buildAppContext(); BaselineValidatorMain main = new BaselineValidatorMain(); ImmutableSet<CompareBreak> compareBreaks = main.calculateBaselineBreaks(appContext); System.out.println("BREAKS\n" + compareBreaks.makeString("\n")); assertEquals(2, compareBreaks.size()); ObjectCompareBreak objectBreak = (ObjectCompareBreak) compareBreaks.detect(Predicates .instanceOf(ObjectCompareBreak.class)); FieldCompareBreak dataTypeBreak = (FieldCompareBreak) compareBreaks.select( Predicates.instanceOf(FieldCompareBreak.class)).detect(new Predicate<CompareBreak>() { @Override public boolean accept(CompareBreak each) { return ((FieldCompareBreak) each).getFieldName().equalsIgnoreCase("columnDataType"); } }); assertNotNull(objectBreak); assertNotNull(dataTypeBreak); }
Example #4
Source File: UnitTestDbBuilder.java From obevo with Apache License 2.0 | 6 votes |
private MainDeployerArgs getMainDeployerArgs() { MainDeployerArgs args = new MainDeployerArgs(); if (this.tables != null || this.views != null) { MutableList<Predicate<? super ChangeKey>> predicates = Lists.mutable.empty(); if (this.tables != null) { predicates.add(ChangeKeyPredicateBuilder.newBuilder() .setChangeTypes(ChangeType.TABLE_STR, ChangeType.FOREIGN_KEY_STR, ChangeType.TRIGGER_INCREMENTAL_OLD_STR, ChangeType.STATICDATA_STR) .setObjectNames(Sets.immutable.withAll(this.tables)) .build()); } if (this.views != null) { predicates.add(ChangeKeyPredicateBuilder.newBuilder() .setChangeTypes(ChangeType.VIEW_STR) .setObjectNames(Sets.immutable.withAll(this.views)) .build()); } args.setChangeInclusionPredicate(Predicates.or(predicates)); } args.setAllChangesets(true); // for unit tests, we always want all changes to deploy return args; }
Example #5
Source File: MithraCacheLoaderRuntimeConfigTestUtil.java From reladomo with Apache License 2.0 | 6 votes |
private List<String> detectNotFullTopLevelObjects(final Map<String, MithraObjectConfigurationType> allDefinedClasses, CacheLoaderType cacheLoaderType) { final List<String> notFullClassNames = FastList.newList(); MutableListMultimap<String,TopLevelLoaderType> classesByName = ListAdapter.adapt(cacheLoaderType.getTopLevelLoaders()).groupBy(new Function<TopLevelLoaderType, String>() { @Override public String valueOf(final TopLevelLoaderType topLevelLoaderType) { MithraObjectConfigurationType objectConfigurationType = allDefinedClasses.get(topLevelLoaderType.getClassToLoad()); if (objectConfigurationType == null || !objectConfigurationType.getCacheType().isFull()) { notFullClassNames.add(topLevelLoaderType.getClassToLoad()); } return topLevelLoaderType.getClassToLoad() + topLevelLoaderType.getSourceAttributes() + topLevelLoaderType.getFactoryClass(); } }); RichIterable<RichIterable<TopLevelLoaderType>> listOfDupes = classesByName.multiValuesView().select(Predicates.attributeGreaterThan(Functions.getSizeOf(), 1)); this.assertEmpty("Found duplicates in TopLevel Loader:" + this.printListOfTopLevelLoaderType(listOfDupes), listOfDupes.toList()); return notFullClassNames; }
Example #6
Source File: MithraCacheLoaderRuntimeConfigTestUtil.java From reladomo with Apache License 2.0 | 6 votes |
private List<String> detectNotFullDependentObjects(final Map<String, MithraObjectConfigurationType> allDefinedClasses, CacheLoaderType cacheLoaderType) { final List<String> notFullClassNames = FastList.newList(); MutableListMultimap<String,DependentLoaderType> classesByName = ListAdapter.adapt(cacheLoaderType.getDependentLoaders()).groupBy(new Function<DependentLoaderType, String>() { @Override public String valueOf(final DependentLoaderType dependentLoaderType) { final String className = dependentLoaderType.getRelationship().substring(0, dependentLoaderType.getRelationship().lastIndexOf(".")); MithraObjectConfigurationType objectConfigurationType = allDefinedClasses.get(className); if (objectConfigurationType == null || !objectConfigurationType.getCacheType().isFull()) { notFullClassNames.add(dependentLoaderType.getRelationship()); } return dependentLoaderType.getRelationship() + dependentLoaderType.getHelperFactoryClass(); } }); RichIterable<RichIterable<DependentLoaderType>> listOfDupes = classesByName.multiValuesView().select(Predicates.attributeGreaterThan(Functions.getSizeOf(), 1)); this.assertEmpty("Found duplicates in Dependent Relationship:" + this.printListOfDependentLoaderType(listOfDupes), listOfDupes.toList()); return notFullClassNames; }
Example #7
Source File: ExercisesDetachedObjects.java From reladomo-kata with Apache License 2.0 | 6 votes |
@Test public void testQ5() { int peopleBefore = new PersonList(PersonFinder.all()).count(); int jangosBefore = new PersonList(PersonFinder.name().eq("Jango Fett")).count(); Assert.assertEquals(1, jangosBefore); Person jangoFett = PersonFinder.findOne(PersonFinder.name().eq("Jango Fett")); this.makePersistedClone(jangoFett); int peopleAfter = new PersonList(PersonFinder.all()).count(); PersonList jangosAfter = new PersonList(PersonFinder.name().eq("Jango Fett")); Assert.assertEquals(peopleBefore + 1, peopleAfter); Verify.assertSize(2, jangosAfter); Verify.assertAllSatisfy(jangosAfter, Predicates.attributeEqual(PersonFinder.name(), "Jango Fett")); Verify.assertAllSatisfy(jangosAfter, Predicates.attributeEqual(PersonFinder.age(), 25)); Verify.assertAllSatisfy(jangosAfter, Predicates.attributeEqual(PersonFinder.country(), "MA")); }
Example #8
Source File: DbDeployer.java From obevo with Apache License 2.0 | 6 votes |
private Predicate<? super ChecksumEntry> getPlatformInclusionPredicate(DbEnvironment env) { // 1) exclude those tables that are excluded by default from source code, e.g. explain tables or others that users configure ImmutableSet<Predicate<? super ChecksumEntry>> schemaObjectNamePredicates = env.getSchemas().collect(new Function<Schema, Predicate<? super ChecksumEntry>>() { @Override public Predicate<? super ChecksumEntry> valueOf(Schema schema) { return schema.getObjectExclusionPredicateBuilder().build(ChecksumEntry.TO_OBJECT_TYPE, ChecksumEntry.TO_NAME1); } }); // 2) exclude the audit tables MutableMultimap<String, String> tablesToExclude = Multimaps.mutable.set.empty(); tablesToExclude.putAll(ChangeType.TABLE_STR, Sets.immutable.with( env.getPlatform().convertDbObjectName().valueOf(getArtifactDeployerDao().getAuditContainerName()), env.getPlatform().convertDbObjectName().valueOf(dbChecksumManager.getChecksumContainerName()), env.getPlatform().convertDbObjectName().valueOf(getDeployExecutionDao().getExecutionContainerName()), env.getPlatform().convertDbObjectName().valueOf(getDeployExecutionDao().getExecutionAttributeContainerName()) )); ObjectTypeAndNamePredicateBuilder auditTablePredicateBuilder = new ObjectTypeAndNamePredicateBuilder(tablesToExclude.toImmutable(), ObjectTypeAndNamePredicateBuilder.FilterType.EXCLUDE); Predicates<? super ChecksumEntry> auditTablePredicate = auditTablePredicateBuilder.build(ChecksumEntry.TO_OBJECT_TYPE, ChecksumEntry.TO_NAME1); return auditTablePredicate.and(schemaObjectNamePredicates); }
Example #9
Source File: ObjectTypeAndNamePredicateBuilderTest.java From obevo with Apache License 2.0 | 5 votes |
@Test public void testStringParsingWithExclusionDefault() { ObjectTypeAndNamePredicateBuilder parse = ObjectTypeAndNamePredicateBuilder.parse("TABLE~tab1,tab2;VIEW~view1", ObjectTypeAndNamePredicateBuilder.FilterType.EXCLUDE); Predicates<? super Pair<String, String>> predicate = parse.build(Functions.<String>firstOfPair(), (Function<Pair<String, String>, String>) (Function) Functions.<String>secondOfPair()); assertTrue(predicate.accept(Tuples.pair("OTHER", "otherInclude"))); assertFalse(predicate.accept(Tuples.pair("TABLE", "tab1"))); assertFalse(predicate.accept(Tuples.pair("TABLE", "tab2"))); assertTrue(predicate.accept(Tuples.pair("TABLE", "tabNo"))); assertFalse(predicate.accept(Tuples.pair("VIEW", "view1"))); assertTrue(predicate.accept(Tuples.pair("VIEW", "viewInclude"))); }
Example #10
Source File: ObjectTypeAndNamePredicateBuilderTest.java From obevo with Apache License 2.0 | 5 votes |
@Test public void testStringParsing() { ObjectTypeAndNamePredicateBuilder parse = ObjectTypeAndNamePredicateBuilder.parse("TABLE~tab1,tab2;-VIEW~view1", null); Predicates<? super Pair<String, String>> predicate = parse.build(Functions.<String>firstOfPair(), (Function<Pair<String, String>, String>) (Function) Functions.<String>secondOfPair()); assertTrue(predicate.accept(Tuples.pair("OTHER", "otherInclude"))); assertTrue(predicate.accept(Tuples.pair("TABLE", "tab1"))); assertTrue(predicate.accept(Tuples.pair("TABLE", "tab2"))); assertFalse(predicate.accept(Tuples.pair("TABLE", "tabNo"))); assertFalse(predicate.accept(Tuples.pair("VIEW", "view1"))); assertTrue(predicate.accept(Tuples.pair("VIEW", "viewInclude"))); }
Example #11
Source File: BaselineTableChangeParser.java From obevo with Apache License 2.0 | 5 votes |
@Override public ImmutableList<ChangeInput> value(final ChangeType defaultChangeType, final FileObject file, String fileContent, final String objectName, final String schema, TextMarkupDocumentSection packageMetadata) { MutableList<String> sqls = MultiLineStringSplitter.createSplitterOnSpaceAndLine("GO").valueOf(fileContent); sqls = sqls.reject(Predicates.attributePredicate(StringFunctions.trim(), StringPredicates.empty())); MutableList<String> sortedSqls = this.sortSqls(sqls); MutableList<ChangeInput> changes = sortedSqls.zipWithIndex().collect( new Function<Pair<String, Integer>, ChangeInput>() { @Override public ChangeInput valueOf(Pair<String, Integer> object) { String content = object.getOne(); int index = object.getTwo(); ChangeType changeType = getChangeType(content, defaultChangeType); String changeName = "baseline-change-" + index; boolean active = true; String rollbackIfAlreadyDeployedCommand = null; String rollbackContent = null; ChangeInput change = new ChangeInput(false); change.setChangeKey(new ChangeKey(schema, changeType, objectName, changeName)); change.setOrder(index); change.setContentHash(contentHashStrategy.hashContent(content)); change.setContent(content); change.setRollbackIfAlreadyDeployedContent(rollbackIfAlreadyDeployedCommand); change.setActive(active); change.setRollbackContent(rollbackContent); change.setFileLocation(file); return change; } }); return changes.toImmutable(); }
Example #12
Source File: LookupPredicateBuilder.java From obevo with Apache License 2.0 | 5 votes |
public static <T> Predicates<? super T> convert(Function<? super T, String> typeFunction, ImmutableCollection<String> patterns) { if (patterns.isEmpty()) { return Predicates.alwaysTrue(); } else { return Predicates.attributePredicate(typeFunction, convert(patterns)); } }
Example #13
Source File: MainDeployerArgs.java From obevo with Apache License 2.0 | 5 votes |
public void setAllChangesets(boolean allChangesets) { if (allChangesets) { this.setChangesetPredicate(Predicates.alwaysTrue()); } else { this.setChangesetPredicate(null); } }
Example #14
Source File: ObjectTypeAndNamePredicateBuilder.java From obevo with Apache License 2.0 | 5 votes |
private static <T> Predicate<T> getObjectTypeAndNamePredicate( Function<? super T, String> typeFunction, ImmutableCollection<String> typePatterns, boolean negate, Function<? super T, String> nameFunction, ImmutableCollection<String> namePatterns) { Predicates<? super T> typePredicate = LookupPredicateBuilder.convert(typeFunction, typePatterns); Predicates<? super T> namePredicate = LookupPredicateBuilder.convert(nameFunction, namePatterns); if (negate) { namePredicate = Predicates.not(namePredicate); } return Predicates.or(Predicates.not(typePredicate), namePredicate); }
Example #15
Source File: ObjectTypeAndNamePredicateBuilder.java From obevo with Apache License 2.0 | 5 votes |
/** * Builds the predicate on object type and name based on the input functions passed in. */ public <T> Predicates<? super T> build(final Function<? super T, String> objectTypeFunction, final Function<? super T, String> objectNameFunction) { if (objectNamesByType.isEmpty()) { if (filterType == null || filterType.isEmptyInputResult()) { return Predicates.alwaysTrue(); } else { return Predicates.alwaysFalse(); } } RichIterable<Predicate<? super T>> typePredicates = objectNamesByType.keyMultiValuePairsView().toList().collect(new Function<Pair<String, RichIterable<String>>, Predicate<? super T>>() { @Override public Predicate<? super T> valueOf(Pair<String, RichIterable<String>> pair) { String objectType = pair.getOne(); RichIterable<String> objectPatterns = pair.getTwo(); boolean negatePredicate = filterType == FilterType.EXCLUDE; if (objectType.startsWith("-")) { objectType = objectType.substring(1); negatePredicate = true; } Predicate<T> objectTypeAndNamePredicate = getObjectTypeAndNamePredicate( objectTypeFunction, Lists.immutable.with(objectType), negatePredicate, objectNameFunction, objectPatterns.toList().toImmutable() ); return objectTypeAndNamePredicate; } }); if (filterType == null || filterType == FilterType.EXCLUDE) { return Predicates.and(typePredicates); } else { return Predicates.or(typePredicates); } }
Example #16
Source File: ArtifactRestrictions.java From obevo with Apache License 2.0 | 5 votes |
public static Predicate2<Restrictable, Environment> apply() { return new Predicate2<Restrictable, Environment>() { @Override public boolean accept(Restrictable restrictable, Environment env) { ImmutableList<ArtifactRestrictions> restrictions = restrictable.getRestrictions(); if (restrictions == null) { return true; } return Predicates.and(restrictions).accept(env); } }; }
Example #17
Source File: ExercisesAuditOnly.java From reladomo-kata with Apache License 2.0 | 5 votes |
@Test public void testQ3() { TaskList tasks = this.getTaskHistory(1); Verify.assertAllSatisfy(tasks, Predicates.attributeEqual(TaskFinder.name(), "Build Bridge")); Verify.assertSetsEqual(UnifiedSet.newSetWith( Timestamp.valueOf("1965-01-01 06:00:00.0"), Timestamp.valueOf("1967-01-01 11:30:22.0"), Timestamp.valueOf("1990-01-01 06:00:00.0")), tasks.asEcList().collect(TaskFinder.processingDateFrom()).toSet()); }
Example #18
Source File: ReportTest.java From analysis-model with MIT License | 5 votes |
/** * Ensures that each method that creates a copy of another issue instance also copies the corresponding properties. */ @Test void shouldCopyProperties() { Report expected = new Report(); expected.addAll(HIGH, NORMAL_1, NORMAL_2, LOW_2_A, LOW_2_B, LOW_FILE_3); expected.logInfo("Hello"); expected.logInfo("World!"); expected.logError("Boom!"); Report copy = expected.copy(); assertThat(copy).isEqualTo(expected); assertThatAllIssuesHaveBeenAdded(copy); Report report = new Report(); report.addAll(expected); assertThat(report).isEqualTo(expected); assertThatAllIssuesHaveBeenAdded(report); Report empty = expected.copyEmptyInstance(); assertThat(empty).isEmpty(); assertThat(empty.getErrorMessages()).isEqualTo(expected.getErrorMessages()); assertThat(empty.getInfoMessages()).isEqualTo(expected.getInfoMessages()); assertThat(empty.getDuplicatesSize()).isEqualTo(expected.getDuplicatesSize()); Report filtered = expected.filter(Predicates.alwaysTrue()); assertThat(filtered).isEqualTo(expected); assertThatAllIssuesHaveBeenAdded(filtered); }
Example #19
Source File: ChangesetDeploymentsTest.java From obevo with Apache License 2.0 | 5 votes |
private void checkForIndex(DbDeployerAppContext dbDeployerAppContext, final String tableName, String indexName, boolean shouldExist) { final DbMetadataManager dbMetadataManager = dbDeployerAppContext.getDbMetadataManager(); DaTable tableInfo = dbMetadataManager.getTableInfo(new PhysicalSchema("SCHEMA1"), tableName, new DaSchemaInfoLevel().setRetrieveTableIndexes(true)); DaIndex index = tableInfo.getIndices().detect(Predicates.attributeEqual(DaIndex.TO_NAME, indexName)); assertEquals("Index " + indexName + " should exist==" + shouldExist, shouldExist, index != null); }
Example #20
Source File: DbEnvironment.java From obevo with Apache License 2.0 | 5 votes |
public ImmutableList<Group> getGroups() { // ideally, the groups are defined in the groups field; however, we have not enforced this in the past, and most // folks just define the groups via the permission schemes. Hence, we add this extra getter here to allow // clients to get the groups they need MutableSet<String> groupNames = permissions.flatCollect(new Function<Permission, Iterable<Grant>>() { @Override public Iterable<Grant> valueOf(Permission permission) { return permission.getGrants(); } }).flatCollect(new Function<Grant, Iterable<String>>() { @Override public Iterable<String> valueOf(Grant grant) { return grant.getGrantTargets().get(GrantTargetType.GROUP); } }).toSet(); MutableSet<Group> permissionGroups = groupNames.collect(new Function<String, Group>() { @Override public Group valueOf(String name) { return new Group(name); } }); permissionGroups.removeIf(Predicates.attributeIn(new Function<Group, Object>() { @Override public Object valueOf(Group group1) { return group1.getName(); } }, this.groups.collect(new Function<Group, String>() { @Override public String valueOf(Group group) { return group.getName(); } }))); // ensure that we don't duplicate groups across the permissions and config groups list return this.groups.newWithAll(permissionGroups); }
Example #21
Source File: DbDeployer.java From obevo with Apache License 2.0 | 5 votes |
@Override public void doPostDeployAction(DbEnvironment env, final ImmutableList<Change> sourceChanges) { if (env.isChecksumDetectionEnabled()) { if (!dbChecksumManager.isInitialized()) { // need this check done here to account for existing clients dbChecksumManager.initialize(); } dbChecksumManager.applyChecksumDiffs(Predicates.and(getPlatformInclusionPredicate(env), getSourceChangesInclusionPredicate(env, sourceChanges))); } }
Example #22
Source File: DbDeployer.java From obevo with Apache License 2.0 | 5 votes |
private Predicate<? super ChecksumEntry> getSourceChangesInclusionPredicate(final DbEnvironment env, final ImmutableList<Change> sourceChanges) { // 3) only include the predicate types that we care about ImmutableSet<String> requiredValidationObjectTypes = env.getPlatform().getRequiredValidationObjectTypes(); ImmutableSet<ChecksumEntryInclusionPredicate> checksumEntryPredicates = requiredValidationObjectTypes.collect(new Function<String, ChecksumEntryInclusionPredicate>() { @Override public ChecksumEntryInclusionPredicate valueOf(String changeType) { return createLookupIndexForObjectType(env, sourceChanges, changeType); } }); return Predicates.or(checksumEntryPredicates); }
Example #23
Source File: TableSyncher.java From obevo with Apache License 2.0 | 5 votes |
private RichIterable<DaIndex> createIdealIndices(RichIterable<DaTable> tables) { Multimap<String, DaIndex> indexMap = tables.flatCollect(DaTable.TO_INDICES).groupBy( new Function<DaIndex, String>() { @Override public String valueOf(DaIndex index) { return index.getName() + ":" + index.getParent().getName(); } } ); return indexMap.multiValuesView().collect(new Function<RichIterable<DaIndex>, DaIndex>() { @Override public DaIndex valueOf(RichIterable<DaIndex> indices) { if (indices.size() == 1) { return indices.getFirst(); } DaIndex candidate = indices.detect(DaIndex::isUnique); if (candidate != null) { return candidate; } candidate = indices.detect(Predicates.attributeEqual(DaIndex::getIndexType, DaIndexType.CLUSTERED)); if (candidate != null) { return candidate; } return indices.getFirst(); } }); }
Example #24
Source File: AbstractDbMetadataManagerIT.java From obevo with Apache License 2.0 | 5 votes |
private void verify_FUNC_WITH_OVERLOAD(Multimap<String, DaRoutine> routinesByName, String routineName) { if (isFuncOverloadSupported()) { routineName = convertName(routineName); Verify.assertSize(3, routinesByName.get(routineName)); MutableList<DaRoutine> routines = routinesByName.get(routineName).toList().toSortedListBy(DaRoutine.TO_DEFINITION); Verify.assertAllSatisfy(routines, Predicates.attributeEqual(Functions.chain(DaRoutine.TO_SCHEMA, DaSchema.TO_NAME), getSchemaName())); if (!isOnlySpSupported()) { Verify.assertAllSatisfy(routines, Predicates.attributeEqual(DaRoutine.TO_ROUTINE_TYPE, DaRoutineType.function)); } Verify.assertSize(3, routines.collect(DaRoutine.TO_SPECIFIC_NAME).toSet()); assertThat(routines.get(0).getDefinition(), equalToIgnoringWhiteSpace(get_FUNC_WITH_OVERLOAD_1())); assertThat(routines.get(1).getDefinition(), equalToIgnoringWhiteSpace(get_FUNC_WITH_OVERLOAD_2())); assertThat(routines.get(2).getDefinition(), equalToIgnoringWhiteSpace(get_FUNC_WITH_OVERLOAD_3())); } else { Verify.assertSize(1, routinesByName.get(routineName)); DaRoutine routine = routinesByName.get(routineName).toList().get(0); assertEquals(routineName, routine.getName()); assertEquals(getSchemaName(), routine.getSchema().getName()); if (!isOnlySpSupported()) { assertEquals(DaRoutineType.function, routine.getRoutineType()); } assertThat(routine.getSpecificName(), not(isEmptyString())); assertThat(routine.getDefinition(), equalToIgnoringWhiteSpace(get_FUNC_WITH_OVERLOAD_3())); } }
Example #25
Source File: PostgreSqlDbPlatform.java From obevo with Apache License 2.0 | 5 votes |
@Override public ImmutableSet<String> getRequiredValidationObjectTypes() { // there is currently a quirk w/ PostgreSQL where view SQL definitions will not have the objects qualified w/ // the schema name in the connection that creates the SQL; but in subsequent connections, it will be qualified. // Until we work out this issue, we will exclude views from PostgreSQL processing. return super.getRequiredValidationObjectTypes() .reject(Predicates.equal(ChangeType.VIEW_STR)); }
Example #26
Source File: Db2lookRevengTest.java From obevo with Apache License 2.0 | 5 votes |
@Test public void testSchemaExtraction() { ImmutableList<RevengPattern> patterns = Db2lookReveng.getRevengPatterns().select(Predicates.attributeEqual(RevengPattern.TO_CHANGE_TYPE, "VIEW")); RevengPattern revengPattern = patterns.get(0); assertEquals("MYVIEW", revengPattern.evaluate("CREATE or REPLACE VIEW SCHEMA.MYVIEW AS ABC DEF GHI").getPrimaryName()); assertEquals("MYVIEW", revengPattern.evaluate("CREATE or REPLACE VIEW \"SCHEMA\".\"MYVIEW\" AS ABC DEF GHI").getPrimaryName()); assertEquals("MYVIEW", revengPattern.evaluate("CREATE or REPLACE VIEW MYVIEW AS ABC DEF GHI").getPrimaryName()); assertEquals("MYVIEW", revengPattern.evaluate("CREATE or REPLACE VIEW \"MYVIEW\" AS ABC DEF GHI").getPrimaryName()); }
Example #27
Source File: MemSqlDbPlatform.java From obevo with Apache License 2.0 | 5 votes |
@Override public ImmutableSet<String> getRequiredValidationObjectTypes() { // there is currently a quirk w/ PostgreSQL where view SQL definitions will not have the objects qualified w/ // the schema name in the connection that creates the SQL; but in subsequent connections, it will be qualified. // Until we work out this issue, we will exclude views from PostgreSQL processing. return super.getRequiredValidationObjectTypes() .reject(Predicates.equal(ChangeType.VIEW_STR)); }
Example #28
Source File: DbEnvironmentXmlEnricherTest.java From obevo with Apache License 2.0 | 4 votes |
/** * This one has no default specified for autoReorgEnabled */ @Test public void test2() { ImmutableCollection<DbEnvironment> envs = getDeploySystem("./src/test/resources/DbEnvironmentXmlEnricher/system-config-test2.xml"); DbEnvironment env1 = envs.detect(Predicates.attributeEqual(new Function<DbEnvironment, Object>() { @Override public Object valueOf(DbEnvironment dbEnvironment) { return dbEnvironment.getName(); } }, "test1")); Schema schema = env1.getSchemas().detect(it -> it.getName().equals("MYSCHEMA")); assertTrue(schema.getObjectExclusionPredicateBuilder().getObjectNamesByType().isEmpty()); assertEquals("MYSCHEMA", env1.getPhysicalSchema("MYSCHEMA").getPhysicalName()); assertEquals(Lists.mutable.of( FileRetrievalMode.FILE_SYSTEM.resolveSingleFileObject("src/test/resources/DbEnvironmentXmlEnricher") ), env1.getSourceDirs()); assertEquals(Sets.mutable.with("DACT_RO", "DACT_RO_BATCH1", "DACT_RO_BATCH2", "DACT_RW", "DACT_RW_BATCH1", "DACT_RW_BATCH2"), env1.getGroups().collect(new Function<Group, String>() { @Override public String valueOf(Group group) { return group.getName(); } }).toSet()); assertEquals(Sets.mutable.with("CMDRRWDB", "CMDRRODB"), env1.getUsers().collect(new Function<User, String>() { @Override public String valueOf(User user) { return user.getName(); } }).toSet()); assertEquals(DbEnvironmentXmlEnricherTest2DbPlatform.class, env1.getPlatform().getClass()); assertTrue(env1.isAutoReorgEnabled()); assertEquals(',', env1.getDataDelimiter()); assertEquals("null", env1.getNullToken()); assertEquals(1, env1.getSourceDirs().size()); assertEquals(Sets.immutable.with("ext1", "ext2"), env1.getAcceptedExtensions()); }
Example #29
Source File: AbstractDeployerAppContext.java From obevo with Apache License 2.0 | 4 votes |
protected Predicate<? super ChangeKey> getDbChangeFilter() { return Predicates.alwaysTrue(); }
Example #30
Source File: AbstractReveng.java From obevo with Apache License 2.0 | 4 votes |
private MutableList<String> getSqlSnippets(File file) { final MutableList<String> dataLines; dataLines = FileUtilsCobra.readLines(file); dataLines.forEachWithIndex(new ObjectIntProcedure<String>() { @Override public void value(String line, int i) { if (!line.isEmpty() && line.charAt(0) == '\uFEFF') { dataLines.set(i, dataLines.get(i).substring(1)); } if (line.startsWith("--------------------") && dataLines.get(i + 1).startsWith("-- DDL Statements") && dataLines.get(i + 2).startsWith("--------------------")) { dataLines.set(i, ""); dataLines.set(i + 1, ""); dataLines.set(i + 2, ""); } else if (line.startsWith("--------------------") && dataLines.get(i + 2).startsWith("-- DDL Statements") && dataLines.get(i + 4).startsWith("--------------------")) { dataLines.set(i, ""); dataLines.set(i + 1, ""); dataLines.set(i + 2, ""); dataLines.set(i + 3, ""); dataLines.set(i + 4, ""); } else if (line.startsWith("-- DDL Statements for ")) { dataLines.set(i, ""); } // For PostgreSQL if ((line.equals("--") && dataLines.get(i + 1).startsWith("-- Name: ") && dataLines.get(i + 2).equals("--"))) { dataLines.set(i, ""); dataLines.set(i + 1, "GO"); dataLines.set(i + 2, ""); } } }); MutableList<String> sqlSnippets; if (stringSplitter != null) { String data = dataLines .reject(skipLinePredicates != null ? Predicates.or(skipLinePredicates) : (Predicate) Predicates.alwaysFalse()) .makeString(SystemUtils.LINE_SEPARATOR); sqlSnippets = stringSplitter.valueOf(data); } else { // If null, then default each line to being its own parsable statement sqlSnippets = dataLines .reject(skipLinePredicates != null ? Predicates.or(skipLinePredicates) : (Predicate) Predicates.alwaysFalse()); } sqlSnippets = sqlSnippets.collect(new Function<String, String>() { @Override public String valueOf(String sqlSnippet) { return StringUtils.stripStart(sqlSnippet, "\r\n \t"); } }); sqlSnippets = sqlSnippets.select(StringPredicates.notBlank().and(Predicates.noneOf(skipPredicates))); return sqlSnippets; }