@@ -0,0 +1,2958 @@
+package org.marsik.elshelves.backend.test.unit;%0A%0Aimport static org.mockito.Matchers.any;%0Aimport static org.mockito.Mockito.doReturn;%0A%0Aimport javax.persistence.EntityManager;%0Aimport java.util.UUID;%0A%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.marsik.elshelves.backend.entities.Box;%0Aimport org.marsik.elshelves.backend.entities.IdentifiedEntity;%0Aimport org.marsik.elshelves.backend.entities.OwnedEntity;%0Aimport org.marsik.elshelves.backend.entities.Source;%0Aimport org.marsik.elshelves.backend.entities.Type;%0Aimport org.marsik.elshelves.backend.entities.User;%0Aimport org.marsik.elshelves.backend.repositories.BaseIdentifiedEntityRepository;%0Aimport org.marsik.elshelves.backend.repositories.BaseOwnedEntityRepository;%0Aimport org.marsik.elshelves.backend.repositories.BoxRepository;%0Aimport org.marsik.elshelves.backend.repositories.LotRepository;%0Aimport org.marsik.elshelves.backend.repositories.PurchaseRepository;%0Aimport org.marsik.elshelves.backend.repositories.SourceRepository;%0Aimport org.marsik.elshelves.backend.repositories.TransactionRepository;%0Aimport org.marsik.elshelves.backend.repositories.TypeRepository;%0Aimport org.marsik.elshelves.backend.services.LotServiceImpl;%0Aimport org.marsik.elshelves.backend.services.UuidGenerator;%0Aimport org.marsik.elshelves.backend.services.UuidGeneratorImpl;%0Aimport org.mockito.InjectMocks;%0Aimport org.mockito.Mock;%0Aimport org.mockito.Spy;%0Aimport org.springframework.data.repository.Repository;%0A%0Apublic class LotDeliveryTest extends BaseUnitTest %7B%0A    @InjectMocks%0A    LotServiceImpl service;%0A%0A    @Mock%0A    EntityManager entityManager;%0A%0A    @Mock%0A    TypeRepository typeRepository;%0A%0A    @Mock%0A    TransactionRepository transactionRepository;%0A%0A    @Mock%0A    PurchaseRepository purchaseRepository;%0A%0A    @Mock%0A    SourceRepository sourceRepository;%0A%0A    @Mock%0A    LotRepository lotRepository;%0A%0A    @Mock%0A    BoxRepository boxRepository;%0A%0A    @Spy%0A    UuidGenerator uuidGenerator = new UuidGeneratorImpl();%0A%0A    private User user;%0A%0A    @Before%0A    public void setUp() throws Exception %7B%0A        user = randomIdObj(User.class);%0A    %7D%0A%0A    @Test%0A    public void testTypeBasedDelivery() throws Exception %7B%0A        Type type = randomIdObj(Type.class);%0A        Box box = randomIdObj(Box.class);%0A        Source source = randomIdObj(Source.class);%0A        source.setName(%22SOURCE%22);%0A%0A        alwaysReturn(typeRepository, type);%0A        alwaysReturn(boxRepository, box);%0A        alwaysReturn(sourceRepository, source);%0A%0A        service.deliverAdHoc(source, type, box, 10L, null, user);%0A    %7D%0A%0A    private %3CT extends IdentifiedEntity%3E T randomIdObj(Class%3CT%3E cls) throws IllegalAccessException, InstantiationException %7B%0A        T o = cls.newInstance();%0A        o.setId(UUID.randomUUID());%0A        return o;%0A    %7D%0A%0A    private %3CT extends OwnedEntity%3E void alwaysReturn(BaseOwnedEntityRepository%3CT%3E repository, T value) %7B%0A        doReturn(value).when(repository).findById(any());%0A        value.setOwner(user);%0A    %7D%0A%7D%0A

Add basic unit test for ad hoc lot delivery