I have a piece of code which is expected to populated one attribute of response object with Java UUID (UUID.randomUUID()
).
How can I unit test this code from outside to check this behaviour? I don't know the UUID that would be generated inside it.
Sample code which needs to be tested:
// To test whether x attribute was set using an UUID
// instead of hardcode value in the response
class A {
String x;
String y;
}
// Method to test
public A doSomething() {
// Does something
A a = new A();
a.setX( UUID.randomUUID());
return a;
}