JmsDestinationEntityBuilder implements EntityBuilder { @Override public List<Entity> build(Bundle bundle, BundleType bundleType, Document document) { if (bundle instanceof AnnotatedBundle) { Map<String, JmsDestination> jmsDestinationMap = Optional.ofNullable(bundle.getJmsDestinations()).orElse(Collections.emptyMap()); return buildEntities(jmsDestinationMap, ((AnnotatedBundle) bundle).getFullBundle(), bundleType, document); } else { return buildEntities(bundle.getJmsDestinations(), bundle, bundleType, document); } } @Inject  JmsDestinationEntityBuilder(IdGenerator idGenerator); @Override List<Entity> build(Bundle bundle, BundleType bundleType, Document document); @Override @NotNull Integer getOrder();  }
@Test void buildFromEmptyBundle_noConnections() { JmsDestinationEntityBuilder builder = new JmsDestinationEntityBuilder(ID_GENERATOR); final List<Entity> entities = builder.build(new Bundle(), EntityBuilder.BundleType.ENVIRONMENT, DocumentTools.INSTANCE.getDocumentBuilder().newDocument()); assertTrue(entities.isEmpty()); }
@Test void buildDeploymentBundle() { final Bundle bundle = new Bundle(projectInfo); bundle.putAllJmsDestinations(ImmutableMap.of(JMS_DESTINATION_ENTITY_NAME, buildOutbound(bundle, true, true).build())); TestUtils.testDeploymentBundleWithOnlyMapping( new JmsDestinationEntityBuilder(ID_GENERATOR), bundle, DocumentTools.INSTANCE.getDocumentBuilder().newDocument(), EntityTypes.JMS_DESTINATION_TYPE, Stream.of("::" + projectInfo.getGroupName() + "::" + JMS_DESTINATION_ENTITY_NAME + "::" + projectInfo.getVersion()).collect(Collectors.toList()) ); }
@Test void buildJmsDestination_Inbound() { JmsDestinationEntityBuilder builder = new JmsDestinationEntityBuilder(ID_GENERATOR); final Bundle bundle = new Bundle(projectInfo); bundle.putAllJmsDestinations(ImmutableMap.of(JMS_DESTINATION_ENTITY_NAME, buildInbound(bundle, true).build())); final List<Entity> entities = builder.build(bundle, EntityBuilder.BundleType.ENVIRONMENT, DocumentTools.INSTANCE.getDocumentBuilder().newDocument()); assertEquals(1, entities.size()); verifyInbound(entities.get(0)); }
@Test void buildJmsDestination_Inbound_MissingAssociatedService() { JmsDestinationEntityBuilder builder = new JmsDestinationEntityBuilder(ID_GENERATOR); final Bundle bundle = new Bundle(projectInfo); bundle.putAllJmsDestinations(ImmutableMap.of(JMS_DESTINATION_ENTITY_NAME, buildInbound(bundle, false).build())); assertThrows(BundleLoadException.class, () -> builder.build(bundle, EntityBuilder.BundleType.ENVIRONMENT, DocumentTools.INSTANCE.getDocumentBuilder().newDocument())); }
@Test void buildJmsDestination_Outbound() { JmsDestinationEntityBuilder builder = new JmsDestinationEntityBuilder(ID_GENERATOR); final Bundle bundle = new Bundle(projectInfo); bundle.putAllJmsDestinations(ImmutableMap.of(JMS_DESTINATION_ENTITY_NAME, buildOutbound(bundle, true, true).build())); final List<Entity> entities = builder.build(bundle, EntityBuilder.BundleType.ENVIRONMENT, DocumentTools.INSTANCE.getDocumentBuilder().newDocument()); assertEquals(1, entities.size()); verifyOutbound(entities.get(0)); }
@Test void buildJmsDestination_MissingJndiStoredPassword() { JmsDestinationEntityBuilder builder = new JmsDestinationEntityBuilder(ID_GENERATOR); final Bundle bundle = new Bundle(projectInfo); bundle.putAllJmsDestinations(ImmutableMap.of(JMS_DESTINATION_ENTITY_NAME, buildOutbound(bundle, false, true).build())); assertThrows(EntityBuilderException.class, () -> builder.build(bundle, EntityBuilder.BundleType.ENVIRONMENT, DocumentTools.INSTANCE.getDocumentBuilder().newDocument())); }
@Test void buildJmsDestination_MissingDestinationStoredPassword() { JmsDestinationEntityBuilder builder = new JmsDestinationEntityBuilder(ID_GENERATOR); final Bundle bundle = new Bundle(projectInfo); bundle.putAllJmsDestinations(ImmutableMap.of(JMS_DESTINATION_ENTITY_NAME, buildOutbound(bundle, true, false).build())); assertThrows(EntityBuilderException.class, () -> builder.build(bundle, EntityBuilder.BundleType.ENVIRONMENT, DocumentTools.INSTANCE.getDocumentBuilder().newDocument())); }
@Test void buildJmsDestination_TibcoEmsProvider() { JmsDestinationEntityBuilder builder = new JmsDestinationEntityBuilder(ID_GENERATOR); final Bundle bundle = new Bundle(projectInfo); bundle.putAllJmsDestinations(ImmutableMap.of(JMS_DESTINATION_ENTITY_NAME, buildTibcoEmsProvider(bundle, true, true).build())); final List<Entity> entities = builder.build(bundle, EntityBuilder.BundleType.ENVIRONMENT, DocumentTools.INSTANCE.getDocumentBuilder().newDocument()); assertEquals(1, entities.size()); verifyTibcoEmsProvider(entities.get(0)); }
@Test void buildJmsDestination_TibcoEmsProvider_MissingJndiClientAuthPrivateKey() { JmsDestinationEntityBuilder builder = new JmsDestinationEntityBuilder(ID_GENERATOR); final Bundle bundle = new Bundle(projectInfo); bundle.putAllJmsDestinations(ImmutableMap.of(JMS_DESTINATION_ENTITY_NAME, buildTibcoEmsProvider(bundle, false, true).build())); assertThrows(EntityBuilderException.class, () -> builder.build(bundle, EntityBuilder.BundleType.ENVIRONMENT, DocumentTools.INSTANCE.getDocumentBuilder().newDocument())); }
@Test void buildJmsDestination_TibcoEmsProvider_MissingDestinationClientAuthPrivateKey() { JmsDestinationEntityBuilder builder = new JmsDestinationEntityBuilder(ID_GENERATOR); final Bundle bundle = new Bundle(projectInfo); bundle.putAllJmsDestinations(ImmutableMap.of(JMS_DESTINATION_ENTITY_NAME, buildTibcoEmsProvider(bundle, true, false).build())); assertThrows(EntityBuilderException.class, () -> builder.build(bundle, EntityBuilder.BundleType.ENVIRONMENT, DocumentTools.INSTANCE.getDocumentBuilder().newDocument())); }
@Test void buildJmsDestination_WebShpereOverLdapProvider() { JmsDestinationEntityBuilder builder = new JmsDestinationEntityBuilder(ID_GENERATOR); final Bundle bundle = new Bundle(projectInfo); bundle.putAllJmsDestinations(ImmutableMap.of(JMS_DESTINATION_ENTITY_NAME, buildWebShpereMqOverLdapProvider(bundle, true).build())); final List<Entity> entities = builder.build(bundle, EntityBuilder.BundleType.ENVIRONMENT, DocumentTools.INSTANCE.getDocumentBuilder().newDocument()); assertEquals(1, entities.size()); verifyWebShpereMqOverLdapProvider(entities.get(0)); }
@Test void buildJmsDestination_WebShpereOverLdapProvider_MissingDestinationClientAuthPrivateKey() { JmsDestinationEntityBuilder builder = new JmsDestinationEntityBuilder(ID_GENERATOR); final Bundle bundle = new Bundle(projectInfo); bundle.putAllJmsDestinations(ImmutableMap.of(JMS_DESTINATION_ENTITY_NAME, buildWebShpereMqOverLdapProvider(bundle, false).build())); assertThrows(EntityBuilderException.class, () -> builder.build(bundle, EntityBuilder.BundleType.ENVIRONMENT, DocumentTools.INSTANCE.getDocumentBuilder().newDocument())); }