Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zapek committed Nov 16, 2024
1 parent 2dce2ad commit e440fef
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@

import io.xeres.app.api.controller.AbstractControllerTest;
import io.xeres.app.database.model.location.LocationFakes;
import io.xeres.app.job.PeerConnectionJob;
import io.xeres.app.service.LocationService;
import io.xeres.common.rest.connection.ConnectionRequest;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
Expand All @@ -30,6 +32,7 @@
import org.springframework.test.web.servlet.MockMvc;

import java.util.List;
import java.util.Optional;

import static io.xeres.common.rest.PathConfig.CONNECTIONS_PATH;
import static org.hamcrest.Matchers.is;
Expand All @@ -47,6 +50,9 @@ class ConnectionControllerTest extends AbstractControllerTest
@MockBean
private LocationService locationService;

@MockBean
private PeerConnectionJob peerConnectionJob;

@Autowired
public MockMvc mvc;

Expand All @@ -65,4 +71,17 @@ void GetConnectedProfiles_Success() throws Exception

verify(locationService).getConnectedLocations();
}

@Test
void AttemptToConnect_Success() throws Exception
{
var location = LocationFakes.createLocation();
when(locationService.findLocationByLocationId(location.getLocationId())).thenReturn(Optional.of(location));

mvc.perform(putJson(BASE_URL + "/connect", new ConnectionRequest(location.getLocationId().toString(), -1)))
.andExpect(status().isOk());

verify(locationService).findLocationByLocationId(location.getLocationId());
verify(peerConnectionJob).connectImmediately(location, -1);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -360,12 +360,12 @@ private String getAvailability()
setUserOnline(true);
yield "";
}
case AWAY -> " (" + bundle.getString("messaging.status.away") + ")";
case BUSY -> " (" + bundle.getString("messaging.status.busy") + ")";
case AWAY -> " (" + Availability.AWAY + ")";
case BUSY -> " (" + Availability.BUSY + ")";
case OFFLINE ->
{
setUserOnline(false);
yield " (" + bundle.getString("messaging.status.offline") + ")";
yield " (" + Availability.OFFLINE + ")";
}
};
}
Expand Down
5 changes: 0 additions & 5 deletions ui/src/main/resources/i18n/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -256,11 +256,6 @@ messaging.file-requester.send-file=Select File to Send
messaging.send-picture=Select an image to send inline
messaging.send.file=Select a file to send


messaging.status.away=Away
messaging.status.busy=Busy
messaging.status.offline=Disconnected

messaging.warning.title=Warning
messaging.warning.description=The user is currently offline and cannot receive messages.

Expand Down
4 changes: 0 additions & 4 deletions ui/src/main/resources/i18n/messages_fr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,6 @@ messaging.prompt=Ecrivez un message
messaging.file-requester.send-picture=Selectionnez une image à envoyer dans le chat
messaging.file-requester.send-file=Sélectionnez un fichier à transmettre

messaging.status.away=Absent
messaging.status.busy=Occupé
messaging.status.offline=Déconnecté

messaging.warning.title=Attention
messaging.warning.description=L'utilisateur est actuellement déconnecté et ne peut recevoir de messages.

Expand Down

0 comments on commit e440fef

Please sign in to comment.