...

/

Develop the Business Service Tier

Develop the Business Service Tier

Let's see how the business service tier can be developed for a standalone component.

Now it is time to look at the business service tier. We will start with the test for the finding all records operation.

Find all records operation

Press + to interact
@RunWith( SpringJUnit4ClassRunner.class )
@ContextConfiguration( locations = { "classpath:context.xml" } )
@TransactionConfiguration( defaultRollback = true )
@Transactional
public class ProductServiceImplTest {
@Autowired
private ProductService service;
@Test
public void testFindAll() {
Assert.assertEquals(0L, service.findAll().size());
}
}

Let’s look at how to code the corresponding method in the business service. The business service corresponding Spring annotation is @Service, which is used along with the @Transactional annotation. The business service calls the data access tier. But remember that the data access tier uses entities and the business service tier uses data access objects. So, there should be ...