Unit Testing - verify method called
===

I am unit testing a method that takes an object as parameter A, creates an instance of another object, B and populates B's properties with A's. The code then calls a method on a separate class called messageSender.send(B);

I need to verify that send() is called. I have tried the following but it fails saying sendBMessage was called with a different type of B object.

Anyone any idea how to verify messageSender.send(B) is called?

     class MyMailSender{
        MessageSender messageSender;
        
        void sendBMessage(Object A){
           B b = new B();
           b.setId(A.getId()):
        
           messageSender.send(B);
        
        }

    class test{
     @Mock
     private MessageSender messageSender;
     @InjectMocks
     MyMailSender myMailSender;

     void testSendB(){
       A a = new A();
       a.setId(100);
    
       B b = new B();
       b.setId(a.getId());
    
       myMailSender.sendBMessage(a);
    
       verify(messageSender).send(b);
    }