lib/templates/src/test/java/unit/controller/ControllerUnitTest.java.erb in spring-gen-0.2.2 vs lib/templates/src/test/java/unit/controller/ControllerUnitTest.java.erb in spring-gen-0.2.3
- old
+ new
@@ -68,11 +68,11 @@
public void getAllShouldReturnAPageOf<%=@model_name%>() throws Exception {
List<<%=@model_name%>> sampleData = new ArrayList<>();
for (int i = 0; i < 10; i++) {
<%=@model_name%> instance = new <%=@model_name%>();
- instance.setId(i);
+ instance.setId(<%=augment_test_id("i")%>);
sampleData.add(instance);
}
Page<<%=@model_name%>> page = new PageImpl<>(sampleData);
when(<%=@model_name.downcase%>Repository.findAll(any(Pageable.class))).thenReturn(page);
when(pagedResourcesAssembler.toResource(page,<%=@model_name.downcase%>Assembler))
@@ -89,15 +89,15 @@
}
@Test
public void getOneShouldReturnResponseContainingTheDataOfOne<%=@model_name%>AsJson() throws Exception {
<%=@model_name%> instance = new <%=@model_name%>();
- instance.setId(1L);
+ instance.setId(<%=augment_test_id(1)%>);
<%=@model_name%>Resource testResource = new <%=@model_name%>Resource(instance);
- when(<%=@model_name.downcase%>Repository.findOne(1L)).thenReturn(instance);
+ when(<%=@model_name.downcase%>Repository.findOne(<%=augment_test_id(1)%>)).thenReturn(instance);
when(<%=@model_name.downcase%>Assembler.toResource(instance)).thenReturn(testResource);
- ResponseEntity response = testInstance.getOne(1L);
+ ResponseEntity response = testInstance.getOne(<%=augment_test_id(1)%>);
assertEquals(200,response.getStatusCode().value());
- verify(<%=@model_name.downcase%>Repository, times(1)).findOne(1L);
+ verify(<%=@model_name.downcase%>Repository, times(1)).findOne(<%=augment_test_id(1)%>);
verify(<%=@model_name.downcase%>Assembler, times(1)).toResource(instance);
}
}
\ No newline at end of file