Skip to content

Commit

Permalink
test(ZNTA-2297): transunithistory returns bad request on null localei…
Browse files Browse the repository at this point in the history
…d or transunitid
  • Loading branch information
efloden committed Feb 28, 2018
1 parent 4d8ec1b commit 380e991
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
Expand Up @@ -66,4 +66,14 @@ public Response get(String localeId, Long transUnitId) {
historyHandler.getTranslationHistory(localeId, transUnitId);
return Response.ok(result).build();
}

public TransUnitHistoryService() {
}

@java.beans.ConstructorProperties({"historyHandler"})
protected TransUnitHistoryService(
final GetTranslationHistoryHandler historyHandler
) {
this.historyHandler = historyHandler;
}
}
@@ -0,0 +1,39 @@
package org.zanata.rest.editor.service;

import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.zanata.webtrans.server.rpc.GetTranslationHistoryHandler;
import org.zanata.webtrans.shared.rpc.GetTranslationHistoryResult;

import javax.ws.rs.core.Response;

import static org.assertj.core.api.Assertions.assertThat;

public class TransUnitHistoryServiceTest {
private TransUnitHistoryService service;
@Mock
private GetTranslationHistoryHandler historyHandler;

@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
historyHandler = new GetTranslationHistoryHandler();
service = new TransUnitHistoryService(historyHandler);
}

@Test
public void nullOrEmptyLocaleWillReturnBadRequest() {
Long transUnitID = 1L;
Response response = service.get(null, transUnitID);
assertThat(response.getStatus()).isEqualTo(400);
}

@Test
public void nullTransUnitIdWillReturnBadRequest() {
String localeId = "ja";
Response response = service.get(localeId, null);
assertThat(response.getStatus()).isEqualTo(400);
}
}

0 comments on commit 380e991

Please sign in to comment.