You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by "MaximeBrunetPolyconseil (via GitHub)" <gi...@apache.org> on 2024/02/02 10:23:01 UTC
Re: [PR] JAMES-2372 Fixing multiple accounts with Fetchmail [james-project]
MaximeBrunetPolyconseil commented on code in PR #1951:
URL: https://github.com/apache/james-project/pull/1951#discussion_r1475857000
##########
server/protocols/fetchmail/src/test/java/org/apache/james/fetchmail/FetchMailTest.java:
##########
@@ -0,0 +1,76 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ ****************************************************************/
+
+package org.apache.james.fetchmail;
+
+import org.apache.commons.configuration2.BaseHierarchicalConfiguration;
+import org.apache.commons.configuration2.HierarchicalConfiguration;
+import org.apache.commons.configuration2.tree.ImmutableNode;
+import org.apache.james.core.Username;
+import org.apache.james.user.api.UsersRepository;
+import org.junit.jupiter.api.Test;
+import org.mockito.MockedConstruction;
+import org.mockito.Mockito;
+
+import java.util.List;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.tuple;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+class FetchMailTest {
+
+ @Test
+ void shouldAddAccountWithGoodDataFetchMail() throws Exception {
+ try (MockedConstruction<ParsedConfiguration> mockParsedConfiguration = Mockito.mockConstruction(ParsedConfiguration.class)) {
+ UsersRepository fieldLocalUsers = mock(UsersRepository.class);
+ when(fieldLocalUsers.countUsers()).thenReturn(4);
+ when(fieldLocalUsers.list())
+ .thenReturn(List.of(Username.of("user23@domain.com")).iterator())
+ .thenReturn(List.of(Username.of("user23@domain.com")).iterator());
Review Comment:
Thank you for your review. I removed the mock for `UserRepository` and used `MemoryUserRepository`. I also improved the test by adding only one alllocal account as it is only possible to have one for a given fetchmail configuration.
They are no errors otherwise in the new tests. The errors are coming from other modules, the detail is in the CI run. But it will be fix eventually.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org