use of com.redhat.service.bridge.manager.models.Bridge in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class SendToBridgeActionTransformer method transform.
@Override
public BaseAction transform(BaseAction action, String bridgeId, String customerId, String processorId) {
String destinationBridgeId = action.getParameters().getOrDefault(SendToBridgeAction.BRIDGE_ID_PARAM, bridgeId);
Bridge destinationBridge = bridgesService.getReadyBridge(destinationBridgeId, customerId);
Map<String, String> parameters = new HashMap<>();
try {
parameters.put(WebhookAction.ENDPOINT_PARAM, getBridgeWebhookUrl(destinationBridge.getEndpoint()));
parameters.put(WebhookAction.USE_TECHNICAL_BEARER_TOKEN, "true");
} catch (MalformedURLException e) {
throw new ActionProviderException("Can't find events webhook for bridge " + destinationBridgeId);
}
BaseAction transformedAction = new BaseAction();
transformedAction.setType(WebhookAction.TYPE);
transformedAction.setParameters(parameters);
return transformedAction;
}
use of com.redhat.service.bridge.manager.models.Bridge in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class SendToBridgeActionTransformerTest method beforeAll.
@BeforeAll
static void beforeAll() {
bridge = new Bridge();
bridge.setId(BRIDGE_ID);
bridge.setName("bridge01");
bridge.setCustomerId(TEST_CUSTOMER_ID);
bridge.setStatus(ManagedResourceStatus.READY);
bridge.setEndpoint(BRIDGE_ENDPOINT);
otherBridge = new Bridge();
otherBridge.setId(OTHER_BRIDGE_ID);
otherBridge.setName("bridge02");
otherBridge.setCustomerId(TEST_CUSTOMER_ID);
otherBridge.setStatus(ManagedResourceStatus.READY);
otherBridge.setEndpoint(OTHER_BRIDGE_ENDPOINT);
}
use of com.redhat.service.bridge.manager.models.Bridge in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class BridgeDAOTest method testFindByNameAndCustomerId.
@Test
public void testFindByNameAndCustomerId() {
Bridge bridge = buildBridge(TestConstants.DEFAULT_BRIDGE_ID, TestConstants.DEFAULT_BRIDGE_NAME);
bridgeDAO.persist(bridge);
Bridge retrievedBridge = bridgeDAO.findByNameAndCustomerId("not-the-id", TestConstants.DEFAULT_CUSTOMER_ID);
assertThat(retrievedBridge).isNull();
retrievedBridge = bridgeDAO.findByNameAndCustomerId(TestConstants.DEFAULT_BRIDGE_NAME, "not-the-customer-id");
assertThat(retrievedBridge).isNull();
retrievedBridge = bridgeDAO.findByNameAndCustomerId(TestConstants.DEFAULT_BRIDGE_NAME, TestConstants.DEFAULT_CUSTOMER_ID);
assertThat(retrievedBridge).isNotNull();
}
use of com.redhat.service.bridge.manager.models.Bridge in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class BridgeDAOTest method testListByCustomerId.
@Test
public void testListByCustomerId() {
Bridge firstBridge = buildBridge(TestConstants.DEFAULT_BRIDGE_ID, TestConstants.DEFAULT_BRIDGE_NAME);
bridgeDAO.persist(firstBridge);
Bridge secondBridge = buildBridge("mySecondBridgeId", "mySecondBridgeName");
bridgeDAO.persist(secondBridge);
ListResult<Bridge> retrievedBridges = bridgeDAO.findByCustomerId(TestConstants.DEFAULT_CUSTOMER_ID, new QueryInfo(TestConstants.DEFAULT_PAGE, TestConstants.DEFAULT_PAGE_SIZE));
assertThat(retrievedBridges).isNotNull();
assertThat(retrievedBridges.getSize()).isEqualTo(2);
assertThat(retrievedBridges.getTotal()).isEqualTo(2);
assertThat(retrievedBridges.getPage()).isZero();
// Newest istances come first
assertThat(retrievedBridges.getItems().get(1).getId()).isEqualTo(firstBridge.getId());
assertThat(retrievedBridges.getItems().get(0).getId()).isEqualTo(secondBridge.getId());
}
use of com.redhat.service.bridge.manager.models.Bridge in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorDAOTest method findProcessorsToBeDeployedOrDelete.
@Test
@Transactional
public void findProcessorsToBeDeployedOrDelete() {
Bridge b = createBridge();
// To be provisioned
Processor p = createProcessor(b, "foo");
p.setDependencyStatus(ManagedResourceStatus.READY);
processorDAO.getEntityManager().merge(p);
// Already provisioned
Processor q = createProcessor(b, "bob");
q.setStatus(ManagedResourceStatus.READY);
q.setDependencyStatus(ManagedResourceStatus.READY);
processorDAO.getEntityManager().merge(q);
// To be de-provisioned
Processor r = createProcessor(b, "frank");
r.setStatus(ManagedResourceStatus.DEPROVISION);
r.setDependencyStatus(ManagedResourceStatus.DELETED);
processorDAO.getEntityManager().merge(r);
List<Processor> processors = processorDAO.findByShardIdWithReadyDependencies(TestConstants.SHARD_ID);
assertThat(processors.size()).isEqualTo(2);
processors.forEach((px) -> assertThat(px.getName()).isIn("foo", "frank"));
}
Aggregations