You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openmeetings.apache.org by GitBox <gi...@apache.org> on 2020/04/26 03:58:34 UTC

[GitHub] [openmeetings] solomax commented on a change in pull request #68: OPENMEETINGS-2299 Add unit test for recording when sharing wasn't ena…

solomax commented on a change in pull request #68:
URL: https://github.com/apache/openmeetings/pull/68#discussion_r415200660



##########
File path: openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/StreamProcessor.java
##########
@@ -188,6 +188,10 @@ private void handleBroadcastStarted(Client c, final String uid, JSONObject msg)
 			log.error("Failed to start broadcast", e);
 		}
 	}
+	
+	public KStream startBroadcast(KStream stream, StreamDesc sd, String sdpOffer) {

Review comment:
       please add method comments so this method will not be refactored

##########
File path: openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/StreamProcessor.java
##########
@@ -442,9 +446,10 @@ public void stopRecording(Client c) {
 		});
 	}
 
-	void startConvertion(Recording rec) {
+	public boolean startConvertion(Recording rec) {

Review comment:
       does it need to be `public`?

##########
File path: openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/StreamProcessor.java
##########
@@ -442,9 +446,10 @@ public void stopRecording(Client c) {
 		});
 	}
 
-	void startConvertion(Recording rec) {
+	public boolean startConvertion(Recording rec) {
 		IRecordingConverter conv = rec.isInterview() ? interviewConverter : recordingConverter;
 		taskExecutor.execute(() -> conv.startConversion(rec));
+		return true;

Review comment:
       it seems method returns nothing but true
   seems to be useless

##########
File path: openmeetings-core/src/test/java/org/apache/openmeetings/core/remote/TestRecordingFlowMocked.java
##########
@@ -0,0 +1,222 @@
+/*
+
+ * 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.openmeetings.core.remote;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.util.Locale;
+import java.util.logging.StreamHandler;
+
+import org.apache.openmeetings.db.dao.label.LabelDao;
+import org.apache.openmeetings.db.dao.record.RecordingDao;
+import org.apache.openmeetings.db.dao.room.RoomDao;
+import org.apache.openmeetings.db.dao.user.UserDao;
+import org.apache.openmeetings.db.entity.basic.Client;
+import org.apache.openmeetings.db.entity.basic.Client.Activity;
+import org.apache.openmeetings.db.entity.basic.Client.StreamDesc;
+import org.apache.openmeetings.db.entity.label.OmLanguage;
+import org.apache.openmeetings.db.entity.record.Recording;
+import org.apache.openmeetings.db.entity.room.Room;
+import org.apache.openmeetings.db.entity.user.User;
+import org.apache.openmeetings.db.manager.IClientManager;
+import org.junit.Test;
+import org.kurento.client.MediaPipeline;
+import org.kurento.client.Transaction;
+import org.mockito.BDDMockito;
+import org.mockito.Mock;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+
+import com.github.openjson.JSONObject;
+
+@PrepareForTest(LabelDao.class)
+public class TestRecordingFlowMocked extends BaseMockedTest {
+	private static final Long USER_ID = 1L;
+	private static final Long ROOM_ID = 5L;
+	@Mock
+	private UserDao userDao;
+	@Mock
+	private RoomDao roomDao;
+	@Mock
+	private RecordingDao recDao;
+	@Mock
+	private IClientManager cm;
+	
+	//This variable holds a reference to the current client in the room
+	private Client c;
+	
+	//This variable hold a reference to the UID of the StreamDesc that will be created 
+	private String streamDescUID;
+
+	@Override
+	public void setup() {
+		super.setup();
+		when(client.createMediaPipeline(any(Transaction.class))).thenReturn(mock(MediaPipeline.class));
+		User u = new User();
+		u.setId(USER_ID);
+		u.setFirstname("firstname");
+		u.setLastname("lastname");
+		when(userDao.get(USER_ID)).thenReturn(u);
+		doReturn(true).when(handler).isConnected();
+		when(recDao.update(any(Recording.class))).thenAnswer(new Answer<Recording>() {
+			@Override
+			public Recording answer(InvocationOnMock invocation) throws Throwable {
+				Object[] args = invocation.getArguments();
+				Recording r = (Recording) args[0];
+				r.setId(1L);
+				return r;
+			}
+		});
+		
+		PowerMockito.mockStatic(LabelDao.class);

Review comment:
       this should be moved to `@BeforeAll`




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org