From beebeaa4f49e70815a80789ee93f89e8d82f0b89 Mon Sep 17 00:00:00 2001
From: uhensler <urs.hensler@frentix.com>
Date: Thu, 4 Feb 2021 15:34:45 +0100
Subject: [PATCH] OO-5273: Fix unit tests

---
 .../manager/OnlyOfficeServiceImplTest.java         | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/test/java/org/olat/core/commons/services/doceditor/onlyoffice/manager/OnlyOfficeServiceImplTest.java b/src/test/java/org/olat/core/commons/services/doceditor/onlyoffice/manager/OnlyOfficeServiceImplTest.java
index 6784dbb2b78..85cf1c04be8 100644
--- a/src/test/java/org/olat/core/commons/services/doceditor/onlyoffice/manager/OnlyOfficeServiceImplTest.java
+++ b/src/test/java/org/olat/core/commons/services/doceditor/onlyoffice/manager/OnlyOfficeServiceImplTest.java
@@ -81,12 +81,24 @@ public class OnlyOfficeServiceImplTest {
 	}
 	
 	@Test
-	public void shouldNotAllowEditIfAllLicensesInUse() {
+	public void shouldAllowEditIfAlmostAllLicensesInUse() {
+		// Because the access is created before the license check is done,
+		// the access is demanding for the last license.
 		when(onlyOfficeModuleMock.getLicenseEdit()).thenReturn(10);
 		when(documentEditorServiceMock.getAccessCount(any(), any())).thenReturn(Long.valueOf(10));
 		
 		boolean editLicenseAvailable = sut.isEditLicenseAvailable();
 		
+		assertThat(editLicenseAvailable).isTrue();
+	}
+	
+	@Test
+	public void shouldNotAllowEditIfAllLicensesInUse() {
+		when(onlyOfficeModuleMock.getLicenseEdit()).thenReturn(10);
+		when(documentEditorServiceMock.getAccessCount(any(), any())).thenReturn(Long.valueOf(11));
+		
+		boolean editLicenseAvailable = sut.isEditLicenseAvailable();
+		
 		assertThat(editLicenseAvailable).isFalse();
 	}
 
-- 
GitLab