or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

collection-assertions.mddata-assertions.mdindex.mdlookup-cache-assertions.mdtype-assertions.md

data-assertions.mddocs/

0

# Data Structure Assertions

1

2

Fluent assertions for Flink's internal data structures including RowData, ArrayData, MapData, and StringData. These assertions provide comprehensive validation capabilities with automatic type conversion between internal and external representations.

3

4

## RowData Assertions

5

6

Assertions for Flink's internal row data structures with field-level validation and type conversion capabilities.

7

8

```java { .api }

9

public class RowDataAssert extends AbstractAssert<RowDataAssert, RowData> {

10

public RowDataAssert(RowData rowData);

11

12

// Row properties

13

public RowDataAssert hasKind(RowKind kind);

14

public RowDataAssert hasArity(int arity);

15

16

// Field access and validation

17

public StringDataAssert getStringData(int index);

18

public StringAssert getString(int index);

19

public LongAssert getLong(int index);

20

public RowDataAssert isNullAt(int index);

21

public RowDataAssert isNotNullAt(int index);

22

23

// Type conversion

24

public RowDataAssert asGeneric(DataType dataType);

25

public RowDataAssert asGeneric(LogicalType logicalType);

26

/** Requires flink-table-runtime in classpath */

27

public RowAssert asRow(DataType dataType);

28

}

29

```

30

31

### Usage Examples

32

33

```java

34

import static org.apache.flink.table.test.TableAssertions.assertThat;

35

import org.apache.flink.table.data.RowData;

36

import org.apache.flink.types.RowKind;

37

38

// Basic row validation

39

RowData rowData = /* ... */;

40

assertThat(rowData)

41

.hasKind(RowKind.INSERT)

42

.hasArity(3)

43

.isNotNullAt(0)

44

.isNullAt(2);

45

46

// Field value assertions

47

assertThat(rowData)

48

.getString(0).isEqualTo("test")

49

.getLong(1).isEqualTo(42L);

50

51

// Type conversion for comparison

52

RowData expected = /* ... */;

53

DataType dataType = /* ... */;

54

assertThat(rowData)

55

.asGeneric(dataType)

56

.isEqualTo(expected);

57

```

58

59

## Row Assertions

60

61

Assertions for external Row objects used in Table API.

62

63

```java { .api }

64

public class RowAssert extends AbstractAssert<RowAssert, Row> {

65

public RowAssert(Row row);

66

67

public RowAssert hasKind(RowKind kind);

68

public RowAssert hasArity(int arity);

69

}

70

```

71

72

### Usage Examples

73

74

```java

75

import org.apache.flink.types.Row;

76

import org.apache.flink.types.RowKind;

77

78

Row row = Row.of("Alice", 25, true);

79

row.setKind(RowKind.INSERT);

80

81

assertThat(row)

82

.hasKind(RowKind.INSERT)

83

.hasArity(3);

84

```

85

86

## ArrayData Assertions

87

88

Assertions for Flink's internal array data structures.

89

90

```java { .api }

91

public class ArrayDataAssert extends AbstractAssert<ArrayDataAssert, ArrayData> {

92

public ArrayDataAssert(ArrayData arrayData);

93

94

public ArrayDataAssert hasSize(int size);

95

public ArrayDataAssert asGeneric(DataType dataType);

96

public ArrayDataAssert asGeneric(LogicalType logicalType);

97

}

98

```

99

100

### Usage Examples

101

102

```java

103

import org.apache.flink.table.data.ArrayData;

104

import org.apache.flink.table.data.GenericArrayData;

105

106

ArrayData arrayData = new GenericArrayData(new Object[]{1, 2, 3});

107

108

assertThat(arrayData)

109

.hasSize(3);

110

111

// With type conversion

112

DataType arrayType = /* ... */;

113

assertThat(arrayData)

114

.asGeneric(arrayType)

115

.isEqualTo(expectedArray);

116

```

117

118

## MapData Assertions

119

120

Assertions for Flink's internal map data structures.

121

122

```java { .api }

123

public class MapDataAssert extends AbstractAssert<MapDataAssert, MapData> {

124

public MapDataAssert(MapData mapData);

125

126

public MapDataAssert hasSize(int size);

127

public MapDataAssert asGeneric(DataType dataType);

128

public MapDataAssert asGeneric(LogicalType logicalType);

129

}

130

```

131

132

### Usage Examples

133

134

```java

135

import org.apache.flink.table.data.MapData;

136

import org.apache.flink.table.data.GenericMapData;

137

138

Map<Object, Object> map = new HashMap<>();

139

map.put("key1", "value1");

140

map.put("key2", "value2");

141

MapData mapData = new GenericMapData(map);

142

143

// Basic size validation

144

assertThat(mapData)

145

.hasSize(2);

146

147

// Type conversion for comparison

148

DataType mapType = /* ... */;

149

assertThat(mapData)

150

.asGeneric(mapType)

151

.isEqualTo(expectedMap);

152

```

153

154

## StringData Assertions

155

156

Assertions for Flink's internal string data structures.

157

158

```java { .api }

159

public class StringDataAssert extends AbstractAssert<StringDataAssert, StringData> {

160

public StringDataAssert(StringData stringData);

161

162

public StringAssert asString();

163

public ByteArrayAssert asBytes();

164

}

165

```

166

167

### Usage Examples

168

169

```java

170

import org.apache.flink.table.data.StringData;

171

import org.assertj.core.api.ByteArrayAssert;

172

import org.assertj.core.api.StringAssert;

173

174

StringData stringData = StringData.fromString("Hello World");

175

176

assertThat(stringData)

177

.isEqualTo(StringData.fromString("Hello World"));

178

179

// Convert to String for string-specific assertions

180

assertThat(stringData)

181

.asString()

182

.startsWith("Hello")

183

.endsWith("World")

184

.hasLength(11);

185

186

// Convert to byte array for byte-level assertions

187

assertThat(stringData)

188

.asBytes()

189

.hasSize(11)

190

.startsWith("Hello".getBytes());

191

```

192

193

## Generic Data Assertions

194

195

Factory methods for creating assertions when the exact data type is unknown at compile time.

196

197

### Usage Examples

198

199

```java

200

import org.apache.flink.table.types.logical.LogicalType;

201

202

Object data = /* could be RowData, ArrayData, MapData, etc. */;

203

LogicalType logicalType = /* ... */;

204

205

// Creates appropriate assertion type based on actual data type

206

assertThatGenericDataOfType(data, logicalType)

207

.isEqualTo(expectedData);

208

209

// Works with DataType as well

210

DataType dataType = /* ... */;

211

assertThatGenericDataOfType(data, dataType)

212

.isNotNull();

213

```