I think your biggest issue here, while not strictly test related, is your understanding of what the code you've written does (versus what it is supposed to do).
What your code currently does
If your only return statement is return null you will always get null as a return value, which is usually not useful. With that out of the way, let's talk about what we want to replace it with.
It appears your getData method is supposed to return an Object[][] - this is almost always a poor decision. You would be much better off returning something like a List - I'm going to go out on a limb and say this is always better. At least for the next 5 years, you do not want to return an Object[][] unless someone with many years experience signs off on it.
Now we're going to focus on the loop - that's the meat and potatoes of this code.
So It looks like you've got some bass guitars - I personally play a Fender Squire Precision 5 string, that low B has some wobble!
// each line represents one guitar
while ((line = br.readLine()) != null) {
// good - we get the info about each guitar from the line
// parts[0] will be the brand
// parts[1] will be the model
// parts[2] will be the string count
String[] parts = line.split(",");
// now we make a new hash map - but why? We're making a new hash map...
// for every single guitar? it's in the "for each guitar" loop!
// this is clearly a problem
HashMap<String, String> map = new HashMap<String, String>();
// now we're putting it with a key of the brand and a value of the model
// but this will overwrite - if we put("fender","precision");
// and then put("fender","jazz"); then we will effectively lose the fact
// that precision ever existed - this is of course ignoring
// the fact that we never actually can access this data since it was
// created inside the loop
map.put(parts[0], parts[1]);
// oh dear and now we're making an Object[][] - for what?
Object[][] data = new Object[2][7];
// and now we're setting data[0][0] to a value that was never mapped!
// data is an object - it has no value in the map
data[0][0] = map.get(data);
}
I hope this walkthrough shows how the code isn't really doing anything useful, and probably not what you intended.
Normally, I would highly recommend against using Object[][] BUT I'm going to assume you must do it for your lab purposes. We need to clean up this code a little bit.
What your code needs to do
// first we make the object array we want to return OUTSIDE the loop so we don't get a new one every loop
// we want 3 columns, not 2 - column 0 will be brand, column 1 will be model, and column 2 will be string count
// we want to do 7 3 not 3 7
Object[][] data = new Object[7][3];
int rowCount = 0; // we need to know what row of data we're on
while ((line = br.readLine()) != null) {
String[] parts = line.split(",");
data[rowCount][0] = parts[0]; // brand
data[rowCount][1] = parts[1]; // model
data[rowCount][2] = parts[2]; // strings
rowCount = rowCount + 1;
}
return data; // now instead of returning null, we return data
Now this count actually be a lot simpler - String is an Object, thus String[] is an Object[].
Object[][] data = new Object[7][3];
int rowCount = 0;
while ((line = br.readLine()) != null) {
data[rowCount] = line.split(",");
rowCount = rowCount + 1;
}
return data;
But like I said, Object[][] is bad. Better would be to use a domain object - it's much more testable, reusable, debuggable, and reliable.
public class BassGuitar {
private String brand;
private String model;
private int stringCount;
public BassGuitar(String brand, String model, int stringCount) {
this.brand = brand;
this.model = model;
this.stringCount = stringCount;
}
// add getters and setters
}
Now we can do something useful like this:
List list = new ArrayList<>();
while ((line = br.readLine()) != null) {
String[] parts = line.split(",");
String brand = parts[0];
String model = parts[1];
int stringCount = Integer.parseInt(parts[2]);
BassGuitar bass = new BassGuitar(brand, model, stringCount);
list.add(bass);
}
return list; // note, instead of public Object[][] getData() you now have public List getData()
If you really are supposed to be learning about testing, then you need to understand how to write code that is meant to be tested. And Object[][] is very, very hard to test. The only thing harder to test than Object[][] is like ... byte[][] basically.
Now this is a lab - I can promise you that if you blindly take code like this and slap it in your assignment,
your lab instructor will find out when their automated anti-cheat programs googles the lines of code and this post comes up, and
you won't get any better at this in the future. If you have more questions on it, chances are you'll get a faster response from Stack Overflow unless it's more directly related to testing or the testng tag.