Skip to content

Commit

Permalink
Polish ProtobufMessageBuilderRandomizer
Browse files Browse the repository at this point in the history
  • Loading branch information
murdos committed May 16, 2021
1 parent b629d30 commit 2bd196c
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
import org.jeasy.random.EasyRandomParameters;
import org.jeasy.random.api.Randomizer;

/**
* Generate a random Protobuf {@link Message.Builder}.
*/
public class ProtobufMessageBuilderRandomizer implements Randomizer<Message.Builder> {

private final ProtobufMessageRandomizer protobufMessageRandomizer;
Expand All @@ -37,6 +40,7 @@ public ProtobufMessageBuilderRandomizer(
);
}

@SuppressWarnings("unchecked")
private static Class<Message> retrieveMessageClassFromBuilderClass(Class<Message.Builder> messageBuilderClass) {
return (Class<Message>) messageBuilderClass.getEnclosingClass();
}
Expand All @@ -45,4 +49,8 @@ private static Class<Message> retrieveMessageClassFromBuilderClass(Class<Message
public Message.Builder getRandomValue() {
return protobufMessageRandomizer.getRandomValue().toBuilder();
}

public String toString() {
return this.getClass().getSimpleName();
}
}

0 comments on commit 2bd196c

Please sign in to comment.