Skip to content

findMatchingTableRow

Chuck May edited this page Apr 14, 2015 · 4 revisions

API

public Integer findMatchingTableRow(String tableId, String key, String value)
public Integer findMatchingTableRow(String tableId, Map<String, String> context)

Description

For a given table, return the index of the row that matches the supplied input. If there was no match found, null is returned. There are two versions of the this API. The first takes a single key/value combination while the second accepts a context which contains one or more key/values.

Examples

Staging staging = Staging.getInstance(CsDataProvider.getInstance(CsVersion.v020550));

// test looking for a row that does not exist
Assert.assertNull(staging.findMatchingTableRow("size_apa", "size", "996"));

// test by passing in a single key/value
Assert.assertEquals(Integer.valueOf(0), staging.findMatchingTableRow("size_apa", "size", "000"));
Assert.assertEquals(Integer.valueOf(1), staging.findMatchingTableRow("size_apa", "size", "055"));
Assert.assertEquals(Integer.valueOf(1), staging.findMatchingTableRow("size_apa", "size", "988"));
Assert.assertEquals(Integer.valueOf(2), staging.findMatchingTableRow("size_apa", "size", "989"));
Assert.assertEquals(Integer.valueOf(9), staging.findMatchingTableRow("size_apa", "size", "999"));

// test by passing in a context
Map<String, String> context = new HashMap<String, String>();
context.put("size", "992");
Assert.assertEquals(Integer.valueOf(5), staging.findMatchingTableRow("size_apa", context));

// test matching a table that has multiple inputs
context = new HashMap<String, String>();
context.put("t", "RE");
context.put("n", "U");
context.put("m", "U");
Assert.assertEquals(Integer.valueOf(167), staging.findMatchingTableRow("summary_stage_rpa", context));

Clone this wiki locally