Complete repository refactoring - method renaming (#575)
* Split Tag management Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Repo method naming schame applied. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * findAll returns slice instead of page. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Complete javadoc. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Allow null values again. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Readability improvements. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Forgot a method. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Fixed broken completed filter. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
@@ -168,19 +168,19 @@ public class AmqpAuthenticationMessageHandler extends BaseAmqpService {
|
||||
}
|
||||
|
||||
if (fileResource.getSha1() != null) {
|
||||
return artifactManagement.findFirstArtifactBySHA1(fileResource.getSha1());
|
||||
return artifactManagement.findFirstBySHA1(fileResource.getSha1());
|
||||
}
|
||||
|
||||
if (fileResource.getFilename() != null) {
|
||||
return artifactManagement.findArtifactByFilename(fileResource.getFilename());
|
||||
return artifactManagement.getByFilename(fileResource.getFilename());
|
||||
}
|
||||
|
||||
if (fileResource.getArtifactId() != null) {
|
||||
return artifactManagement.findArtifact(fileResource.getArtifactId());
|
||||
return artifactManagement.get(fileResource.getArtifactId());
|
||||
}
|
||||
|
||||
if (fileResource.getSoftwareModuleFilenameResource() != null) {
|
||||
return artifactManagement.findByFilenameAndSoftwareModule(
|
||||
return artifactManagement.getByFilenameAndSoftwareModule(
|
||||
fileResource.getSoftwareModuleFilenameResource().getFilename(),
|
||||
fileResource.getSoftwareModuleFilenameResource().getSoftwareModuleId());
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ public class AmqpMessageDispatcherService extends BaseAmqpService {
|
||||
LOG.debug("targetAssignDistributionSet retrieved for controller {}. I will forward it to DMF broker.",
|
||||
assignedEvent.getControllerId());
|
||||
|
||||
targetManagement.findTargetByControllerID(assignedEvent.getControllerId())
|
||||
targetManagement.getByControllerID(assignedEvent.getControllerId())
|
||||
.ifPresent(target -> sendUpdateMessageToTarget(assignedEvent.getTenant(), target,
|
||||
assignedEvent.getActionId(), assignedEvent.getModules()));
|
||||
|
||||
|
||||
@@ -137,8 +137,8 @@ public class AmqpControllerAuthenticationTest {
|
||||
.thenReturn(CONFIG_VALUE_FALSE);
|
||||
|
||||
final ControllerManagement controllerManagement = mock(ControllerManagement.class);
|
||||
when(controllerManagement.findByControllerId(anyString())).thenReturn(Optional.of(targteMock));
|
||||
when(controllerManagement.findByTargetId(any(Long.class))).thenReturn(Optional.of(targteMock));
|
||||
when(controllerManagement.getByControllerId(anyString())).thenReturn(Optional.of(targteMock));
|
||||
when(controllerManagement.get(any(Long.class))).thenReturn(Optional.of(targteMock));
|
||||
|
||||
when(targteMock.getSecurityToken()).thenReturn(CONTROLLER_ID);
|
||||
when(targteMock.getControllerId()).thenReturn(CONTROLLER_ID);
|
||||
@@ -159,8 +159,8 @@ public class AmqpControllerAuthenticationTest {
|
||||
new JpaSoftwareModuleType("a key", "a name", null, 1), "a name", null, null, null));
|
||||
testArtifact.setId(1L);
|
||||
|
||||
when(artifactManagementMock.findArtifact(ARTIFACT_ID)).thenReturn(Optional.of(testArtifact));
|
||||
when(artifactManagementMock.findFirstArtifactBySHA1(SHA1)).thenReturn(Optional.of(testArtifact));
|
||||
when(artifactManagementMock.get(ARTIFACT_ID)).thenReturn(Optional.of(testArtifact));
|
||||
when(artifactManagementMock.findFirstBySHA1(SHA1)).thenReturn(Optional.of(testArtifact));
|
||||
|
||||
final AbstractDbArtifact artifact = new ArtifactFilesystem(new File("does not exist"), SHA1,
|
||||
new DbArtifactHash(SHA1, "md5 test"), ARTIFACT_SIZE, null);
|
||||
|
||||
@@ -88,7 +88,7 @@ public class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
|
||||
@Override
|
||||
public void before() throws Exception {
|
||||
super.before();
|
||||
testTarget = targetManagement.createTarget(entityFactory.target().create().controllerId(CONTROLLER_ID)
|
||||
testTarget = targetManagement.create(entityFactory.target().create().controllerId(CONTROLLER_ID)
|
||||
.securityToken(TEST_TOKEN).address(AMQP_URI.toString()));
|
||||
|
||||
this.rabbitTemplate = Mockito.mock(RabbitTemplate.class);
|
||||
@@ -128,8 +128,8 @@ public class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
|
||||
}
|
||||
|
||||
private Message getCaptureAdressEvent(final TargetAssignDistributionSetEvent targetAssignDistributionSetEvent) {
|
||||
final Target target = targetManagement
|
||||
.findTargetByControllerID(targetAssignDistributionSetEvent.getControllerId()).get();
|
||||
final Target target = targetManagement.getByControllerID(targetAssignDistributionSetEvent.getControllerId())
|
||||
.get();
|
||||
final Message sendMessage = createArgumentCapture(target.getAddress());
|
||||
return sendMessage;
|
||||
}
|
||||
@@ -181,8 +181,8 @@ public class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
|
||||
receivedList.add(new ArtifactFilesystem(new File("./test"), artifact.getSha1Hash(),
|
||||
new DbArtifactHash(artifact.getSha1Hash(), null), artifact.getSize(), null));
|
||||
}
|
||||
module = softwareModuleManagement.findSoftwareModuleById(module.getId()).get();
|
||||
dsA = distributionSetManagement.findDistributionSetById(dsA.getId()).get();
|
||||
module = softwareModuleManagement.get(module.getId()).get();
|
||||
dsA = distributionSetManagement.get(dsA.getId()).get();
|
||||
|
||||
final Action action = createAction(dsA);
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@ public class AmqpMessageHandlerServiceTest {
|
||||
public void before() throws Exception {
|
||||
messageConverter = new Jackson2JsonMessageConverter();
|
||||
when(rabbitTemplate.getMessageConverter()).thenReturn(messageConverter);
|
||||
when(artifactManagementMock.findFirstArtifactBySHA1(SHA1)).thenReturn(Optional.empty());
|
||||
when(artifactManagementMock.findFirstBySHA1(SHA1)).thenReturn(Optional.empty());
|
||||
|
||||
amqpMessageHandlerService = new AmqpMessageHandlerService(rabbitTemplate, amqpMessageDispatcherServiceMock,
|
||||
controllerManagementMock, entityFactoryMock);
|
||||
@@ -344,7 +344,7 @@ public class AmqpMessageHandlerServiceTest {
|
||||
messageProperties);
|
||||
|
||||
final Artifact localArtifactMock = mock(Artifact.class);
|
||||
when(artifactManagementMock.findFirstArtifactBySHA1(anyString())).thenReturn(Optional.of(localArtifactMock));
|
||||
when(artifactManagementMock.findFirstBySHA1(anyString())).thenReturn(Optional.of(localArtifactMock));
|
||||
when(controllerManagementMock.getActionForDownloadByTargetAndSoftwareModule(anyObject(), anyObject()))
|
||||
.thenThrow(EntityNotFoundException.class);
|
||||
|
||||
@@ -372,7 +372,7 @@ public class AmqpMessageHandlerServiceTest {
|
||||
when(localArtifactMock.getSha1Hash()).thenReturn(SHA1);
|
||||
|
||||
final AbstractDbArtifact dbArtifactMock = mock(AbstractDbArtifact.class);
|
||||
when(artifactManagementMock.findFirstArtifactBySHA1(SHA1)).thenReturn(Optional.of(localArtifactMock));
|
||||
when(artifactManagementMock.findFirstBySHA1(SHA1)).thenReturn(Optional.of(localArtifactMock));
|
||||
when(controllerManagementMock.hasTargetArtifactAssigned(securityToken.getControllerId(), SHA1))
|
||||
.thenReturn(true);
|
||||
when(artifactManagementMock.loadArtifactBinary(anyString())).thenReturn(Optional.of(dbArtifactMock));
|
||||
|
||||
@@ -399,7 +399,7 @@ public class AmqpAuthenticationMessageHandlerIntegrationTest extends AbstractAmq
|
||||
}
|
||||
|
||||
private Target createTarget(final String controllerId) {
|
||||
return targetManagement.createTarget(
|
||||
return targetManagement.create(
|
||||
entityFactory.target().create().controllerId(controllerId).securityToken(TARGET_SECRUITY_TOKEN));
|
||||
}
|
||||
|
||||
|
||||
@@ -108,13 +108,13 @@ public class AmqpMessageDispatcherServiceIntegrationTest extends AmqpServiceInte
|
||||
final String controllerId = TARGET_PREFIX + "sendDeleteMessage";
|
||||
|
||||
registerAndAssertTargetWithExistingTenant(controllerId, 1);
|
||||
targetManagement.deleteTarget(controllerId);
|
||||
targetManagement.deleteByControllerID(controllerId);
|
||||
assertDeleteMessage(controllerId);
|
||||
}
|
||||
|
||||
private void waitUntilTargetStatusIsPending(final String controllerId) {
|
||||
waitUntil(() -> {
|
||||
final Optional<Target> findTargetByControllerID = targetManagement.findTargetByControllerID(controllerId);
|
||||
final Optional<Target> findTargetByControllerID = targetManagement.getByControllerID(controllerId);
|
||||
return findTargetByControllerID.isPresent()
|
||||
&& TargetUpdateStatus.PENDING.equals(findTargetByControllerID.get().getUpdateStatus());
|
||||
});
|
||||
|
||||
@@ -165,7 +165,7 @@ public abstract class AmqpServiceIntegrationTest extends AbstractAmqpIntegration
|
||||
Assert.assertThat(dsModules,
|
||||
SoftwareModuleJsonMatcher.containsExactly(downloadAndUpdateRequest.getSoftwareModules()));
|
||||
|
||||
final Target updatedTarget = waitUntilIsPresent(() -> targetManagement.findTargetByControllerID(controllerId));
|
||||
final Target updatedTarget = waitUntilIsPresent(() -> targetManagement.getByControllerID(controllerId));
|
||||
|
||||
assertThat(updatedTarget.getSecurityToken()).isEqualTo(downloadAndUpdateRequest.getTargetSecurityToken());
|
||||
}
|
||||
@@ -199,7 +199,7 @@ public abstract class AmqpServiceIntegrationTest extends AbstractAmqpIntegration
|
||||
}
|
||||
|
||||
protected void assertAllTargetsCount(final long expectedTargetsCount) {
|
||||
assertThat(targetManagement.countTargetsAll()).isEqualTo(expectedTargetsCount);
|
||||
assertThat(targetManagement.count()).isEqualTo(expectedTargetsCount);
|
||||
}
|
||||
|
||||
private Message assertReplyMessageHeader(final EventTopic eventTopic, final String controllerId) {
|
||||
@@ -226,14 +226,14 @@ public abstract class AmqpServiceIntegrationTest extends AbstractAmqpIntegration
|
||||
final int existingTargetsAfterCreation, final TargetUpdateStatus expectedTargetStatus,
|
||||
final String createdBy) {
|
||||
createAndSendTarget(target, TENANT_EXIST);
|
||||
final Target registerdTarget = waitUntilIsPresent(() -> targetManagement.findTargetByControllerID(target));
|
||||
final Target registerdTarget = waitUntilIsPresent(() -> targetManagement.getByControllerID(target));
|
||||
assertAllTargetsCount(existingTargetsAfterCreation);
|
||||
assertTarget(registerdTarget, expectedTargetStatus, createdBy);
|
||||
}
|
||||
|
||||
protected void registerSameTargetAndAssertBasedOnVersion(final String controllerId,
|
||||
final int existingTargetsAfterCreation, final TargetUpdateStatus expectedTargetStatus) {
|
||||
final int version = controllerManagement.findByControllerId(controllerId).get().getOptLockRevision();
|
||||
final int version = controllerManagement.getByControllerId(controllerId).get().getOptLockRevision();
|
||||
createAndSendTarget(controllerId, TENANT_EXIST);
|
||||
final Target registeredTarget = waitUntilIsPresent(() -> findTargetBasedOnNewVersion(controllerId, version));
|
||||
assertAllTargetsCount(existingTargetsAfterCreation);
|
||||
@@ -241,7 +241,7 @@ public abstract class AmqpServiceIntegrationTest extends AbstractAmqpIntegration
|
||||
}
|
||||
|
||||
private Optional<Target> findTargetBasedOnNewVersion(final String controllerId, final int version) {
|
||||
final Optional<Target> target2 = controllerManagement.findByControllerId(controllerId);
|
||||
final Optional<Target> target2 = controllerManagement.getByControllerId(controllerId);
|
||||
if (version < target2.get().getOptLockRevision()) {
|
||||
return target2;
|
||||
}
|
||||
@@ -305,7 +305,7 @@ public abstract class AmqpServiceIntegrationTest extends AbstractAmqpIntegration
|
||||
|
||||
protected void assertUpdateAttributes(final String controllerId, final Map<String, String> attributes) {
|
||||
final Target findByControllerId = waitUntilIsPresent(
|
||||
() -> controllerManagement.findByControllerId(controllerId));
|
||||
() -> controllerManagement.getByControllerId(controllerId));
|
||||
final Map<String, String> controllerAttributes = targetManagement
|
||||
.getControllerAttributes(findByControllerId.getControllerId());
|
||||
assertThat(controllerAttributes.size()).isEqualTo(attributes.size());
|
||||
|
||||
Reference in New Issue
Block a user