@Test public void createFailsValidation() { Identity identity = new Identity(UUID.randomUUID()); ProfileContact contact = new ProfileContact(1, "email", new DefaultContactData("a@"), true); ProfileContacts contacts = new ProfileContacts(Lists.newArrayList(contact)); Observable<Result> result = service.create(identity, contacts); assertEquals(Result.withClientCause("Invalid Contacts"), result.toBlocking().first()); }
@Test public void createWithValidInput() { Identity identity = new Identity(UUID.randomUUID()); ProfileContact contact = new ProfileContact(1, "email", new DefaultContactData("*****@*****.**"), true); ProfileContacts contacts = new ProfileContacts(Lists.newArrayList(contact)); when(loader.create(identity, contact)).thenReturn(Observable.just(Boolean.TRUE)); Observable<Result> result = service.create(identity, contacts); assertEquals(Result.success(), result.toBlocking().first()); }
@Test public void createFailsInternalUpdate() throws Exception { Identity identity = new Identity(UUID.randomUUID()); ProfileContact contact = new ProfileContact(1, "email", new DefaultContactData("*****@*****.**"), true); ProfileContacts contacts = new ProfileContacts(Lists.newArrayList(contact)); when(loader.create(identity, contact)).thenReturn(Observable.just(Boolean.FALSE)); Observable<Result> result = service.create(identity, contacts); assertEquals( Result.withServerCause("There was an unexpected error processing your request."), result.toBlocking().first()); }