Skip to content

Commit

Permalink
Fixed supply mapper to map alse the user
Browse files Browse the repository at this point in the history
  • Loading branch information
viktorKhan committed Mar 21, 2024
1 parent 253fb3f commit 48ed742
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@

import org.lucoenergia.conluz.domain.admin.supply.Supply;
import org.lucoenergia.conluz.domain.shared.BaseMapper;
import org.lucoenergia.conluz.infrastructure.admin.user.UserEntityMapper;
import org.springframework.stereotype.Component;

@Component
public class SupplyEntityMapper extends BaseMapper<SupplyEntity, Supply> {

private final UserEntityMapper userEntityMapper;

public SupplyEntityMapper(UserEntityMapper userEntityMapper) {
this.userEntityMapper = userEntityMapper;
}

@Override
public Supply map(SupplyEntity entity) {
return new Supply.Builder()
Expand All @@ -16,6 +23,7 @@ public Supply map(SupplyEntity entity) {
.withPartitionCoefficient(entity.getPartitionCoefficient())
.withEnabled(entity.getEnabled())
.withName(entity.getName())
.withUser(userEntityMapper.map(entity.getUser()))
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.lucoenergia.conluz.domain.admin.supply.Supply;
import org.lucoenergia.conluz.infrastructure.admin.user.UserEntityMapper;

class SupplyEntityMapperTest {

private final SupplyEntityMapper mapper = new SupplyEntityMapper();
private final UserEntityMapper userEntityMapper = new UserEntityMapper();
private final SupplyEntityMapper mapper = new SupplyEntityMapper(userEntityMapper);

@Test
void testMap() {
Expand All @@ -19,5 +21,6 @@ void testMap() {
Assertions.assertEquals(entity.getAddress(), result.getAddress());
Assertions.assertEquals(entity.getPartitionCoefficient(), result.getPartitionCoefficient());
Assertions.assertEquals(entity.getEnabled(), result.getEnabled());
Assertions.assertEquals(entity.getUser().getPersonalId(), result.getUser().getPersonalId());
}
}

0 comments on commit 48ed742

Please sign in to comment.