Search in sources :

Example 46 with MetaData

use of com.axway.ats.rbv.MetaData in project ats-framework by Axway.

the class Test_SimpleMonitorListener method monitorGetAllMachingMetaData.

@Test
public void monitorGetAllMachingMetaData() throws RbvException {
    DbFieldsRule dbRule = new DbStringFieldRule("", "key1", "value101", MatchRelation.EQUALS, "monitorGetAllMachingMetaData", false);
    Monitor monitor = new Monitor("monitor1", matchable, dbRule, pollingParams, true, false, false);
    List<Monitor> monitors = new ArrayList<Monitor>();
    monitors.add(monitor);
    SimpleMonitorListener listener = new SimpleMonitorListener(monitors);
    listener.evaluateMonitors(TIME_END_POLL);
    List<MetaData> matchingMetaData = monitor.getAllMatchedMetaData();
    assertEquals(1, matchingMetaData.size());
    ArrayList<String> results = new ArrayList<String>();
    results.add((String) matchingMetaData.get(0).getProperty("key1"));
    assertTrue(results.contains("value10") || results.contains("value00"));
}
Also used : Monitor(com.axway.ats.rbv.Monitor) SimpleMonitorListener(com.axway.ats.rbv.SimpleMonitorListener) MetaData(com.axway.ats.rbv.MetaData) ArrayList(java.util.ArrayList) DbFieldsRule(com.axway.ats.rbv.db.rules.DbFieldsRule) DbStringFieldRule(com.axway.ats.rbv.db.rules.DbStringFieldRule) Test(org.junit.Test)

Example 47 with MetaData

use of com.axway.ats.rbv.MetaData in project ats-framework by Axway.

the class Test_FileSystemFolder method getNewMetadataChangeLastModified.

@Test
public void getNewMetadataChangeLastModified() throws Exception {
    expectNew(SystemOperations.class, "localhost:0000").andReturn(systemOperations).times(7);
    expect(systemOperations.getOperatingSystemType()).andReturn(OperatingSystemType.LINUX);
    // now we call getNewMetaData() 3 times
    expect(fileSystemOperations.findFiles(path, ".*", true, true, false)).andReturn(fileList).times(3);
    // 3 times x 2 files
    expectNew(FileSystemOperations.class, "localhost:0000").andReturn(fileSystemOperations).times(7);
    expect(fileSystemOperations.getFileUniqueId(file1)).andReturn(file1_hash).times(2);
    expect(fileSystemOperations.getFileUniqueId(file2)).andReturn(file2_hash).times(3);
    // modify the modification timestamp of file1 for the last getNewMetaData() call
    expect(fileSystemOperations.getFileUniqueId(file1)).andReturn(file1_hash_changed);
    replayAll();
    FileSystemFolder folder = (FileSystemFolder) storage.getFolder(new FileSystemFolderSearchTerm(path, null, true, false));
    folder.open();
    List<MetaData> list = folder.getNewMetaData();
    assertEquals(2, list.size());
    for (MetaData metaData : list) {
        ((FileSystemMetaData) metaData).getFilePackage();
    }
    assertEquals(0, folder.getNewMetaData().size());
    assertEquals(1, folder.getNewMetaData().size());
    verifyAll();
}
Also used : MetaData(com.axway.ats.rbv.MetaData) FileSystemMetaData(com.axway.ats.rbv.filesystem.FileSystemMetaData) FileSystemFolder(com.axway.ats.rbv.filesystem.FileSystemFolder) FileSystemFolderSearchTerm(com.axway.ats.rbv.filesystem.FileSystemFolderSearchTerm) FileSystemMetaData(com.axway.ats.rbv.filesystem.FileSystemMetaData) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) BaseTest(com.axway.ats.rbv.BaseTest) Test(org.junit.Test)

Example 48 with MetaData

use of com.axway.ats.rbv.MetaData in project ats-framework by Axway.

the class Test_FileContentRule method isMatchNegative.

@Test
public void isMatchNegative() throws Exception {
    expect(testFilePackage.grep(EXPRESSION, false)).andReturn(new String[0]);
    replayAll();
    FileContentRule rule = new FileContentRule(EXPRESSION, RULE_NAME, false, true);
    MetaData metaData = new FileSystemMetaData(testFilePackage);
    assertFalse(rule.isMatch(metaData));
    verifyAll();
}
Also used : FileContentRule(com.axway.ats.rbv.filesystem.rules.FileContentRule) FileSystemMetaData(com.axway.ats.rbv.filesystem.FileSystemMetaData) MetaData(com.axway.ats.rbv.MetaData) FileSystemMetaData(com.axway.ats.rbv.filesystem.FileSystemMetaData) BaseTest(com.axway.ats.rbv.BaseTest) Test(org.junit.Test)

Example 49 with MetaData

use of com.axway.ats.rbv.MetaData in project ats-framework by Axway.

the class Test_FileContentRule method isMatch.

@Test
public void isMatch() throws Exception {
    expect(testFilePackage.grep(EXPRESSION, false)).andReturn(new String[] { EXPRESSION });
    replayAll();
    FileContentRule rule = new FileContentRule(EXPRESSION, RULE_NAME, false, true);
    MetaData metaData = new FileSystemMetaData(testFilePackage);
    assertTrue(rule.isMatch(metaData));
    verifyAll();
}
Also used : FileContentRule(com.axway.ats.rbv.filesystem.rules.FileContentRule) FileSystemMetaData(com.axway.ats.rbv.filesystem.FileSystemMetaData) MetaData(com.axway.ats.rbv.MetaData) FileSystemMetaData(com.axway.ats.rbv.filesystem.FileSystemMetaData) BaseTest(com.axway.ats.rbv.BaseTest) Test(org.junit.Test)

Example 50 with MetaData

use of com.axway.ats.rbv.MetaData in project ats-framework by Axway.

the class MetaExecutor method evaluate.

/**
     * Evaluates the {@link MetaData} received as a parameter against the rules
     * that were previously set.
     * @param metaData the {@link List} of {@link MetaData} to be verified
     *
     * @see com.axway.ats.rbv.executors.Executor#evaluate(java.util.List)
     */
public List<MetaData> evaluate(List<MetaData> metaData) throws RbvException {
    List<MetaData> matched = new ArrayList<MetaData>();
    for (MetaData currentMeta : metaData) {
        if (this.rootRule.isMatch(currentMeta)) {
            log.info("Matched a meta data!");
            // we matched a piece of MetaData - add it to the
            // collection that would be returned as a result
            matched.add(currentMeta);
            if (this.endOnFirstMatch) {
                return matched;
            }
        }
    }
    return matched;
}
Also used : MetaData(com.axway.ats.rbv.MetaData) ArrayList(java.util.ArrayList)

Aggregations

MetaData (com.axway.ats.rbv.MetaData)81 Test (org.junit.Test)76 BaseTest (com.axway.ats.rbv.BaseTest)71 FileSystemMetaData (com.axway.ats.rbv.filesystem.FileSystemMetaData)49 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)45 DbStringFieldRule (com.axway.ats.rbv.db.rules.DbStringFieldRule)17 DbMetaData (com.axway.ats.rbv.db.DbMetaData)16 SnapshotExecutor (com.axway.ats.rbv.executors.SnapshotExecutor)15 FileMd5Rule (com.axway.ats.rbv.filesystem.rules.FileMd5Rule)10 FilePathRule (com.axway.ats.rbv.filesystem.rules.FilePathRule)10 FileSizeRule (com.axway.ats.rbv.filesystem.rules.FileSizeRule)10 FilePackage (com.axway.ats.action.objects.FilePackage)9 ArrayList (java.util.ArrayList)7 FileModtimeRule (com.axway.ats.rbv.filesystem.rules.FileModtimeRule)6 FilePermRule (com.axway.ats.rbv.filesystem.rules.FilePermRule)6 ImapMetaData (com.axway.ats.rbv.imap.ImapMetaData)5 FileContentRule (com.axway.ats.rbv.filesystem.rules.FileContentRule)4 FileSystemFolder (com.axway.ats.rbv.filesystem.FileSystemFolder)3 RbvException (com.axway.ats.rbv.model.RbvException)3 FileSystemOperations (com.axway.ats.action.filesystem.FileSystemOperations)2