Provide a more flexible way to label messages.

I'm not quite sure about chans yet
This commit is contained in:
2016-04-11 15:10:59 +02:00
parent 4f7f80c12a
commit e8ddf90363
9 changed files with 158 additions and 22 deletions

View File

@ -143,10 +143,11 @@ public class BitmessageContextTest {
objects.add(TestUtils.loadObjectMessage(5, "V5Broadcast.payload"));
when(ctx.internals().getInventory().getObjects(eq(address.getStream()), anyLong(), any(ObjectType.class)))
.thenReturn(objects);
when(ctx.addresses().getSubscriptions(anyLong())).thenReturn(Collections.singletonList(address));
ctx.addSubscribtion(address);
verify(ctx.addresses(), times(1)).save(address);
verify(ctx.addresses(), atLeastOnce()).save(address);
assertThat(address.isSubscribed(), is(true));
verify(ctx.internals().getInventory()).getObjects(eq(address.getStream()), anyLong(), any(ObjectType.class));
verify(listener).receive(any(Plaintext.class));
@ -232,6 +233,7 @@ public class BitmessageContextTest {
expected.remove(a.getAddress());
}
}
@Test
public void ensureShortDeterministicAddressesAreCreated() {
final int expected_size = 1;

View File

@ -25,6 +25,7 @@ import ch.dissem.bitmessage.entity.payload.GetPubkey;
import ch.dissem.bitmessage.entity.payload.Msg;
import ch.dissem.bitmessage.factory.Factory;
import ch.dissem.bitmessage.ports.AddressRepository;
import ch.dissem.bitmessage.ports.Labeler;
import ch.dissem.bitmessage.ports.MessageRepository;
import ch.dissem.bitmessage.utils.Singleton;
import ch.dissem.bitmessage.utils.TestBase;
@ -62,7 +63,7 @@ public class DefaultMessageListenerTest extends TestBase {
when(ctx.getAddressRepository()).thenReturn(addressRepo);
when(ctx.getMessageRepository()).thenReturn(messageRepo);
listener = new DefaultMessageListener(ctx, mock(BitmessageContext.Listener.class));
listener = new DefaultMessageListener(ctx, mock(Labeler.class), mock(BitmessageContext.Listener.class));
}
@Test