Since you are new to Unit test framework I suggest you to look at Data Driven Testing i.e. DDT.
Data Driven testing generally means executing a set of steps with multiple sets of data.
Here you create your Data using DataProvider and pass them as an argument to test methods , thus eliminating writing the redundant line of code for test cases.
TestNG is one popular framework for the same.
So in your scenarios u just write one test case
@Test(dataProvider = "type-null-check-Data")
public void test(Foo foo1, Foo foo2){
//Invocation of actual code with foo1 & foo2
//The scenarios can be
// 1. foo1 is null
// 2. foo2 is null
// 3. foo1.type is null
// 4. foo2.type is null
}
Scenarios creation as below
@DataProvider(name="type-null-check-Data")
public Object[][] dataProviderMethod() {
Foo foo1 = new Foo();
foo1.setType(null);
Foo foo2 = new Foo();
foo2.setType("anyValue);
Foo foo3 = new Foo();
foo3.setType("anyValue");
return new Object[][] {
{null, null},
{null, foo1},
{foo1, null},
{foo2, foo3},
};
}