You need to put your program on a know state for the string "B", call createB method with "B" and check the result is what you expect. Then you do that again, with a different state and a different expected result. Like this:
public void testCreateBSucess() {
A a = getInstanceOfA(); // Make sure "B" doesn't exists
B b = a.createB("B");
assertNotNull(b);
}
public void testCreateBFail() {
A a = getInstanceOfA();
a.createB("B"); // Making sure "B" exists
B b = a.createB("B");
assertNull(b);
}