Skip to content
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

UML-3750 added exception for null DOB #2984

Merged
merged 35 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
cb48f1f
UML-3619 wip
allenannom Sep 30, 2024
7377fe5
UML-3619 Convert incoming LPAs to combined format (repository layer)
allenannom Oct 3, 2024
56a1031
Merge branch 'main' of github.com:ministryofjustice/opg-use-an-lpa
allenannom Oct 8, 2024
0f3b45c
Merge branch 'main' of github.com:ministryofjustice/opg-use-an-lpa
allenannom Oct 9, 2024
3aa9414
Merge branch 'main' of github.com:ministryofjustice/opg-use-an-lpa
allenannom Oct 9, 2024
22f452c
Merge branch 'main' of github.com:ministryofjustice/opg-use-an-lpa
allenannom Oct 30, 2024
8730ec4
Merge branch 'main' of github.com:ministryofjustice/opg-use-an-lpa
allenannom Nov 4, 2024
7afb712
Merge branch 'main' of github.com:ministryofjustice/opg-use-an-lpa
allenannom Nov 4, 2024
fc8454e
Merge branch 'main' of github.com:ministryofjustice/opg-use-an-lpa
allenannom Nov 5, 2024
1629499
Merge branch 'main' of github.com:ministryofjustice/opg-use-an-lpa
allenannom Nov 11, 2024
cee3917
Merge branch 'main' of github.com:ministryofjustice/opg-use-an-lpa
allenannom Nov 14, 2024
0062994
Merge branch 'main' of github.com:ministryofjustice/opg-use-an-lpa
allenannom Nov 19, 2024
2d37ddb
Merge branch 'main' of github.com:ministryofjustice/opg-use-an-lpa
allenannom Nov 28, 2024
1b93935
Merge branch 'main' of github.com:ministryofjustice/opg-use-an-lpa
allenannom Nov 29, 2024
e0f99c0
Merge branch 'main' of github.com:ministryofjustice/opg-use-an-lpa
allenannom Dec 3, 2024
15738ef
Merge branch 'main' of github.com:ministryofjustice/opg-use-an-lpa
allenannom Dec 4, 2024
b5b454d
UML-3750 added exception for null DOB
allenannom Dec 5, 2024
1567092
Merge branch 'main' into UML-3750-unable-to-request-activation
allenannom Dec 5, 2024
a482065
UML-3750 updated tests, added explicity exception
allenannom Dec 6, 2024
8cf35a9
Merge branch 'main' of github.com:ministryofjustice/opg-use-an-lpa
allenannom Dec 6, 2024
10eb39d
Merge branch 'UML-3750-unable-to-request-activation' of github.com:mi…
allenannom Dec 6, 2024
ccabd09
Merge branch 'main' into UML-3750-unable-to-request-activation
allenannom Dec 6, 2024
d2dda51
UML-3750 updated tests
allenannom Dec 6, 2024
506502d
UML-3750 updated tests
allenannom Dec 9, 2024
e695aeb
UML-3750 updated tests
allenannom Dec 9, 2024
1aaec78
Merge branch 'main' into UML-3750-unable-to-request-activation
allenannom Dec 9, 2024
33a7843
UML-3750 removed outputting actor data
allenannom Dec 16, 2024
6bbe9b0
Merge branch 'main' into UML-3750-unable-to-request-activation
allenannom Dec 16, 2024
192e447
UML-3750 moved try catch block to cover match logic
allenannom Dec 18, 2024
31cd63b
UML-3750 fixed spacing
allenannom Dec 18, 2024
c275f7e
Merge branch 'main' into UML-3750-unable-to-request-activation
allenannom Dec 18, 2024
c681aaa
Merge branch 'main' into UML-3750-unable-to-request-activation
allenannom Dec 18, 2024
36cf595
Merge branch 'main' into UML-3750-unable-to-request-activation
allenannom Dec 19, 2024
b156fc7
UML-3750 added logger
allenannom Dec 19, 2024
2c10eb0
Merge branch 'main' into UML-3750-unable-to-request-activation
allenannom Dec 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

namespace App\Exception;

use Fig\Http\Message\StatusCodeInterface;
use Throwable;

class ActorDateOfBirthNotSetException extends AbstractApiException
{
public const MESSAGE = 'Actor date of birth is not set';
public const TITLE = 'DOB Not Found';
public const CODE = StatusCodeInterface::STATUS_NOT_FOUND;

public function __construct(?string $message = null, array $additionalData = [], ?Throwable $previous = null)
{
parent::__construct(self::TITLE, $message, self::CODE, $additionalData, $previous);
}
}
23 changes: 21 additions & 2 deletions service-api/app/src/App/src/Service/Lpa/FindActorInLpa.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace App\Service\Lpa;

use App\Exception\ActorDateOfBirthNotSetException;
use App\Service\Lpa\FindActorInLpa\ActorMatch;
use App\Service\Lpa\FindActorInLpa\ActorMatchingInterface;
use App\Service\Lpa\FindActorInLpa\FindActorInLpaInterface;
Expand Down Expand Up @@ -126,18 +127,35 @@ private function checkForActorMatch(ActorMatchingInterface $actor, array $matchD
]
);

$actorDob = null;
try {
cooperaj marked this conversation as resolved.
Show resolved Hide resolved
$actorDob = $actor->getDob()->format('Y-m-d');
} catch (ActorDateOfBirthNotSetException $exception) {
$this->logger->warning(
'Actor DOB is null',
[
'actor_id' => $actor->getUid(),
'error' => $exception->getMessage(),
]
);

return self::NO_MATCH__DOB;
}

$this->logger->debug(
'Doing actor data comparison against actor with id {actor_id}',
[
'actor_id' => $actor->getUid(),
'to_match' => $matchData,
'actor_data' => array_merge($actorData, ['dob' => $actor->getDob()]),
'actor_data' => array_merge($actorData, [
allenannom marked this conversation as resolved.
Show resolved Hide resolved
'dob' => $actorDob
]),
]
);

$match = self::MATCH;

$match = $actor->getDob()->format('Y-m-d') !== $matchData['dob']
$match = $actorDob !== $matchData['dob']
? $match | self::NO_MATCH__DOB
: $match;
$match = $actorData['first_names'] !== $matchData['first_names']
Expand All @@ -150,6 +168,7 @@ private function checkForActorMatch(ActorMatchingInterface $actor, array $matchD
? $match | self::NO_MATCH__POSTCODE
: $match;


if ($match === self::MATCH) {
$this->logger->info(
'User entered data matches for LPA {uId}',
Expand Down
9 changes: 9 additions & 0 deletions service-api/app/src/App/src/Service/Lpa/SiriusPerson.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@

namespace App\Service\Lpa;

use App\Exception\ActorDateOfBirthNotSetException;
use App\Service\Lpa\AccessForAll\AddAccessForAllActorInterface;
use App\Service\Lpa\FindActorInLpa\ActorMatchingInterface;
use App\Service\Lpa\GetAttorneyStatus\GetAttorneyStatusInterface;
use App\Service\Lpa\GetTrustCorporationStatus\GetTrustCorporationStatusInterface;
use ArrayAccess;
use Exception;
use DateTimeImmutable;
use DateTimeInterface;
use IteratorAggregate;
Expand Down Expand Up @@ -80,8 +82,15 @@ public function getPostcode(): string
return (string)$this->person['addresses'][0]['postcode'];
}

/**
* @throws Exception
*/
public function getDob(): DateTimeInterface
{
if (is_null($this->person['dob'])) {
throw new ActorDateOfBirthNotSetException('Actor DOB is not set');
}

return new DateTimeImmutable($this->person['dob']);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use App\Entity\Person;
use App\Entity\Sirius\SiriusLpaAttorney;
use App\Entity\Sirius\SiriusLpaDonor;
use App\Exception\ActorDateOfBirthNotSetException;
use App\Service\Lpa\FindActorInLpa;
use App\Service\Lpa\FindActorInLpa\ActorMatch;
use App\Service\Lpa\GetAttorneyStatus;
Expand Down Expand Up @@ -48,6 +49,7 @@ public function returns_actor_and_lpa_details_if_match_found(?ActorMatch $expect
$this->ghostAttorneyFixtureOld(),
$this->multipleAddressAttorneyFixtureOld(),
$this->activeAttorneyFixtureOld(),
$this->nullDOBAttorneyFixtureOld(),
],
],
);
Expand All @@ -68,9 +70,13 @@ public function returns_actor_and_lpa_details_if_match_found(?ActorMatch $expect
->__invoke($this->activeAttorneyFixtureOld())
->willReturn(AttorneyStatus::ACTIVE_ATTORNEY); // active attorney

$this->getAttorneyStatusProphecy
->__invoke($this->nullDOBAttorneyFixtureOld())
->willReturn(AttorneyStatus::ACTIVE_ATTORNEY); // null DoB

$sut = new FindActorInLpa(
$this->getAttorneyStatusProphecy->reveal(),
$this->loggerProphecy->reveal()
$this->loggerProphecy->reveal(),
);

$matchData = $sut($lpa, $userData);
Expand All @@ -87,6 +93,7 @@ public function returns_actor_and_lpa_details_if_match_found_combined_sirius(
$this->inactiveAttorneyFixture(),
$this->ghostAttorneyFixture(),
$this->activeAttorneyFixture(),
$this->nullDOBAttorneyFixture(),
];

$lpa = new \App\Entity\Sirius\SiriusLpa(
Expand Down Expand Up @@ -129,6 +136,10 @@ public function returns_actor_and_lpa_details_if_match_found_combined_sirius(
->__invoke($this->activeAttorneyFixture())
->willReturn(AttorneyStatus::ACTIVE_ATTORNEY); // active attorney

$this->getAttorneyStatusProphecy
->__invoke($this->nullDOBAttorneyFixture())
->willReturn(AttorneyStatus::ACTIVE_ATTORNEY); // null DoB

$sut = new FindActorInLpa(
$this->getAttorneyStatusProphecy->reveal(),
$this->loggerProphecy->reveal()
Expand Down Expand Up @@ -424,4 +435,45 @@ public static function donorFixture(): SiriusLpaDonor
uId: '700000001111'
);
}

public static function nullDOBAttorneyFixtureOld(): SiriusPerson
{
return new SiriusPerson(
[
'uId' => '7000000055555',
'dob' => null,
'firstname' => 'Testering',
'surname' => 'Testing',
'addresses' => [
[
'postcode' => 'Ab1 2Cd',
],
],
'systemStatus' => true,
]
);
}

public static function nullDOBAttorneyFixture(): SiriusLpaAttorney
{
return new SiriusLpaAttorney(
addressLine1: null,
addressLine2: null,
addressLine3: null,
country: null,
county: null,
dob: null,
email: null,
firstname: 'Testering',
id: '7',
middlenames: null,
otherNames: null,
postcode: 'PY1 3Kd',
surname: 'Person',
systemStatus: null,
town: null,
type: null,
uId: '700000001111'
);
}
}
Loading