-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GreenCityUBS bug in saving events #975
Conversation
@@ -981,6 +981,7 @@ void testSetOrderDetailIfPaidAndPriceLessThanPaidSum() { | |||
verify(orderRepository).updateOrderPointsToUse(1L, 0); | |||
} | |||
|
|||
// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to delete it, I forgot
} | ||
if (entry.getValue().longValue() != confirmWasteWas.orElse(0L)) { | ||
if (countOfChanges == 0) { | ||
values.append(OrderHistory.CHANGE_ORDER_DETAILS + " "); | ||
} | ||
values.append(bag.getName()).append(" ").append(capacity).append(" л: ") | ||
.append(confirmWasteWas.orElse(0L)) | ||
.append(confirmWasteWas.orElse(startAmount.orElse(0L))) | ||
.append(" шт на ").append(entry.getValue()).append(" шт."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this text be localized?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it should be localized. Here is a link to this issue: ita-social-projects/GreenCity#5117
if (bagOptional.isPresent() && checkOrderStatusAboutConfirmWaste(order)) { | ||
Optional<Long> confirmWasteWas = Optional.empty(); | ||
Optional<Long> startAmount = Optional.empty(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it is better to use initial
instead of start
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree
Bag bag = bagOptional.get(); | ||
if (Boolean.TRUE.equals(updateOrderRepository.ifRecordExist(orderId, entry.getKey().longValue()) > 0)) { | ||
confirmWasteWas = | ||
Optional.ofNullable(updateOrderRepository.getConfirmWaste(orderId, entry.getKey().longValue())); | ||
startAmount = | ||
Optional.ofNullable(updateOrderRepository.getAmount(orderId, entry.getKey().longValue())); | ||
} | ||
if (entry.getValue().longValue() != confirmWasteWas.orElse(0L)) { | ||
if (countOfChanges == 0) { | ||
values.append(OrderHistory.CHANGE_ORDER_DETAILS + " "); | ||
} | ||
values.append(bag.getName()).append(" ").append(capacity).append(" л: ") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
should this text be localized?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it will be solved in the next issue: ita-social-projects/GreenCity#5117
when(orderRepository.getOrderDetails(anyLong())) | ||
.thenReturn(Optional.ofNullable(ModelUtils.getOrdersStatusFormedDto())); | ||
when(bagRepository.findById(1)).thenReturn(Optional.of(ModelUtils.getTariffBag())); | ||
when(bagRepository.findById(1)).thenReturn(Optional.of(ModelUtils.getTariffBag())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
duplication
*/ | ||
@Query(value = "SELECT AMOUNT FROM ORDER_BAG_MAPPING " | ||
+ "WHERE ORDER_ID = :orderId AND BAG_ID = :bagId", nativeQuery = true) | ||
Long getAmount(Long orderId, Long bagId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we use JPA naming here and not use nativeQuery
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. I'll change it
@@ -1000,6 +1001,27 @@ void testSetOrderDetailConfirmed() { | |||
verify(updateOrderRepository).updateConfirm(anyInt(), anyLong(), anyLong()); | |||
} | |||
|
|||
@Test | |||
void testSetOrderDetailConfirmed2() { | |||
when(orderRepository.findById(1L)).thenReturn(Optional.ofNullable(ModelUtils.getOrdersStatusConfirmedDto())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add verify
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
@Test | ||
void testSetOrderDetailConfirmed2() { | ||
when(orderRepository.findById(1L)).thenReturn(Optional.ofNullable(ModelUtils.getOrdersStatusConfirmedDto())); | ||
when(bagRepository.findCapacityById(1)).thenReturn(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add verify
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
doNothing().when(updateOrderRepository).updateConfirm(anyInt(), anyLong(), anyLong()); | ||
when(orderRepository.getOrderDetails(anyLong())) | ||
.thenReturn(Optional.ofNullable(ModelUtils.getOrdersStatusFormedDto())); | ||
when(bagRepository.findById(1)).thenReturn(Optional.of(ModelUtils.getTariffBag())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add verify
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
.thenReturn(Optional.ofNullable(ModelUtils.getOrdersStatusFormedDto())); | ||
when(bagRepository.findById(1)).thenReturn(Optional.of(ModelUtils.getTariffBag())); | ||
when(bagRepository.findById(1)).thenReturn(Optional.of(ModelUtils.getTariffBag())); | ||
when(updateOrderRepository.ifRecordExist(any(), any())).thenReturn(1L); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add verify
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
Bag bag = bagOptional.get(); | ||
if (Boolean.TRUE.equals(updateOrderRepository.ifRecordExist(orderId, entry.getKey().longValue()) > 0)) { | ||
confirmWasteWas = | ||
Optional.ofNullable(updateOrderRepository.getConfirmWaste(orderId, entry.getKey().longValue())); | ||
initialAmount = | ||
Optional.ofNullable(updateOrderRepository.getAmount(orderId, entry.getKey().longValue())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like the UpdateOrderRepository
class should be renamed because it not only updates orders
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I renamed this interface and variables accordingly.
add getAmount in UpdateOrderDetailRepository
…ository change name of variables updateOrderRepository on orderDetailRepository
9fa1c1b
to
567d0fb
Compare
Kudos, SonarCloud Quality Gate passed! |
Green City UBS bug in writing order history PR
Summary Of Issue :
Create a new order. Change the confirmed number of bags. Open order history. The changed order details show that the quantity has been changed from 0 to "Підтверджена к-ть" .

It is expected that the changed order details show that the quantity has been changed from "Планована к-ть" to "Підтверджена к-ть"
Issue Link :
ita-social-projects/GreenCity#5058
Summary Of Changes :
Code reviewers
Added
add getAmount method in UpdateOrderDetailRepository
add test for new lines of code
Changed
change method collectEventAboutSetOrderDetails in UBSManagementServiceImpl
Deleted
How to test :
CHECK LIST
dev
branch.NEED_REVIEW
andREADY_FOR_REVIEW
labels are added.