Examples of BlueprintEntity


Examples of org.apache.ambari.server.orm.entities.BlueprintEntity

    verify(entityManagerProvider, entityManager);
  }

  @Test
  public void testCreate() {
    BlueprintEntity entity = new BlueprintEntity();

    // set expectations
    entityManager.persist(eq(entity));
    replay(entityManager);
View Full Code Here

Examples of org.apache.ambari.server.orm.entities.BlueprintEntity

    verify(entityManagerProvider, entityManager);
  }

  @Test
  public void testMerge() {
    BlueprintEntity entity = new BlueprintEntity();
    BlueprintEntity entity2 = new BlueprintEntity();

    // set expectations
    expect(entityManager.merge(eq(entity))).andReturn(entity2);
    replay(entityManager);
View Full Code Here

Examples of org.apache.ambari.server.orm.entities.BlueprintEntity

    verify(entityManagerProvider, entityManager);
  }

  @Test
  public void testRemove() {
    BlueprintEntity entity = new BlueprintEntity();
    BlueprintEntity entity2 = new BlueprintEntity();

    // set expectations
    expect(entityManager.merge(eq(entity))).andReturn(entity2);
    entityManager.remove(eq(entity2));
    replay(entityManager);
View Full Code Here

Examples of org.apache.ambari.server.orm.entities.BlueprintEntity

    verify(entityManagerProvider, entityManager);
  }

  @Test
  public void testRemoveByName() {
    BlueprintEntity entity = new BlueprintEntity();
    BlueprintDAO dao = new BlueprintDAO();
    dao.entityManagerProvider = entityManagerProvider;

    expect(entityManager.find(eq(BlueprintEntity.class), eq("test"))).andReturn(entity);
    entityManager.remove(entity);
View Full Code Here

Examples of org.apache.ambari.server.orm.entities.BlueprintEntity

   *
   * @return blueprint entity for the given name
   * @throws IllegalArgumentException no blueprint with the given name found
   */
  protected BlueprintEntity getExistingBlueprint(String blueprintName) {
    BlueprintEntity blueprint = blueprintDAO.findByName(blueprintName);
    if (blueprint == null) {
      throw new IllegalArgumentException("Specified blueprint doesn't exist: " + blueprintName);
    }
    return blueprint;
  }
View Full Code Here

Examples of org.apache.ambari.server.orm.entities.BlueprintEntity

          String conditionalService = stack.getConditionalServiceForDependency(dependency);
          if (conditionalService != null && ! services.contains(conditionalService)) {
            continue;
          }

          BlueprintEntity   entity          = hostGroup.getBlueprintEntity();
          String            dependencyScope = dependency.getScope();
          String            componentName   = dependency.getComponentName();
          AutoDeployInfo    autoDeployInfo  = dependency.getAutoDeploy();
          boolean           resolved        = false;
View Full Code Here

Examples of org.apache.ambari.server.orm.entities.BlueprintEntity

  public void testGetResourcesNoPredicate() throws SystemException, UnsupportedPropertyException,
                                                   NoSuchParentResourceException, NoSuchResourceException {
    Request request = createNiceMock(Request.class);

    ResourceProvider provider = createProvider();
    BlueprintEntity entity = createEntity(getTestProperties().iterator().next());

    List<BlueprintEntity> results = new ArrayList<BlueprintEntity>();
    results.add(entity);

    // set expectations
View Full Code Here

Examples of org.apache.ambari.server.orm.entities.BlueprintEntity

    Request request = createNiceMock(Request.class);

    ResourceProvider provider = createProvider();
    Set<Map<String, Object>> testProperties = getTestProperties();
    setConfigurationProperties(testProperties);
    BlueprintEntity entity = createEntity(testProperties.iterator().next());

    List<BlueprintEntity> results = new ArrayList<BlueprintEntity>();
    results.add(entity);

    // set expectations
View Full Code Here

Examples of org.apache.ambari.server.orm.entities.BlueprintEntity

  @Test
  public void testDeleteResources() throws SystemException, UnsupportedPropertyException,
                                           NoSuchParentResourceException, NoSuchResourceException {

    ResourceProvider provider = createProvider();
    BlueprintEntity blueprintEntity = createEntity(getTestProperties().iterator().next());

    // set expectations
    expect(dao.findByName(BLUEPRINT_NAME)).andReturn(blueprintEntity);
    dao.removeByName(blueprintEntity.getBlueprintName());
    expectLastCall();
    replay(dao);

    Predicate predicate = new EqualsPredicate<String>(
        BlueprintResourceProvider.BLUEPRINT_NAME_PROPERTY_ID, BLUEPRINT_NAME);
View Full Code Here

Examples of org.apache.ambari.server.orm.entities.BlueprintEntity

        PropertyHelper.getKeyPropertyIds(Resource.Type.Blueprint),
        null);
  }

  private BlueprintEntity createEntity(Map<String, Object> properties) {
    BlueprintEntity entity = new BlueprintEntity();
    entity.setBlueprintName((String) properties.get(BlueprintResourceProvider.BLUEPRINT_NAME_PROPERTY_ID));
    entity.setStackName((String) properties.get(BlueprintResourceProvider.STACK_NAME_PROPERTY_ID));
    entity.setStackVersion((String) properties.get(BlueprintResourceProvider.STACK_VERSION_PROPERTY_ID));

    Set<Map<String, Object>> hostGroupProperties = (Set<Map<String, Object>>) properties.get(
        BlueprintResourceProvider.HOST_GROUP_PROPERTY_ID);

    Collection<HostGroupEntity> hostGroups = new ArrayList<HostGroupEntity>();
    for (Map<String, Object> groupProperties : hostGroupProperties) {
      HostGroupEntity hostGroup = new HostGroupEntity();
      hostGroups.add(hostGroup);
      hostGroup.setName((String) groupProperties.get(BlueprintResourceProvider.HOST_GROUP_NAME_PROPERTY_ID));
      hostGroup.setCardinality((String) groupProperties.get(BlueprintResourceProvider.HOST_GROUP_CARDINALITY_PROPERTY_ID));
      hostGroup.setConfigurations(new ArrayList<HostGroupConfigEntity>());

      Set<Map<String, String>> setComponentProperties = (Set<Map<String, String>>) groupProperties.get(
          BlueprintResourceProvider.COMPONENT_PROPERTY_ID);

      Collection<HostGroupComponentEntity> components = new ArrayList<HostGroupComponentEntity>();
      for (Map<String, String> compProperties : setComponentProperties) {
        HostGroupComponentEntity component = new HostGroupComponentEntity();
        components.add(component);
        component.setName(compProperties.get(BlueprintResourceProvider.COMPONENT_NAME_PROPERTY_ID));
      }
      hostGroup.setComponents(components);

    }
    entity.setHostGroups(hostGroups);


    Collection<Map<String, String>> configProperties = (Collection<Map<String, String>>) properties.get(
        BlueprintResourceProvider.CONFIGURATION_PROPERTY_ID);
    Map<String, String> configData = new HashMap<String, String>();
    Collection<BlueprintConfigEntity> configs = new ArrayList<BlueprintConfigEntity>();
    if (configProperties != null) {
      for (Map<String, String> config : configProperties) {
        BlueprintConfigEntity configEntity = new BlueprintConfigEntity();
        for (Map.Entry<String, String> entry : config.entrySet()) {
          String absolutePropName = entry.getKey();

          int idx = absolutePropName.indexOf('/');
          if (configEntity.getType() == null) {
            configEntity.setType(absolutePropName.substring(0, idx));
          }
          configData.put(absolutePropName.substring(idx + 1), entry.getValue());
        }
        configEntity.setConfigData(gson.toJson(configData));
        configs.add(configEntity);
      }
    }
    entity.setConfigurations(configs);

    return entity;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.