Ejemplo n.º 1
0
  @SuppressWarnings("unchecked")
  @Test
  public void testImageIdNullsEverythingElse() {
    Supplier<Set<? extends Location>> locations =
        Suppliers.<Set<? extends Location>>ofInstance(ImmutableSet.<Location>of());
    Supplier<Set<? extends Image>> images =
        Suppliers.<Set<? extends Image>>ofInstance(ImmutableSet.<Image>of());
    Supplier<Set<? extends Hardware>> hardwares =
        Suppliers.<Set<? extends Hardware>>ofInstance(ImmutableSet.<Hardware>of());
    Location defaultLocation = createMock(Location.class);
    Provider<TemplateOptions> optionsProvider = createMock(Provider.class);
    Provider<TemplateBuilder> templateBuilderProvider = createMock(Provider.class);

    replay(defaultLocation);
    replay(optionsProvider);
    replay(templateBuilderProvider);

    TemplateBuilderImpl template =
        createTemplateBuilder(
            null,
            locations,
            images,
            hardwares,
            defaultLocation,
            optionsProvider,
            templateBuilderProvider);

    template.imageDescriptionMatches("imageDescriptionMatches");
    template.imageNameMatches("imageNameMatches");
    template.imageVersionMatches("imageVersionMatches");
    template.osDescriptionMatches("osDescriptionMatches");
    template.osFamily(OsFamily.CENTOS);
    template.osArchMatches("osArchMatches");

    assertEquals(template.osArch, "osArchMatches");
    assertEquals(template.imageDescription, "imageDescriptionMatches");
    assertEquals(template.imageName, "imageNameMatches");
    assertEquals(template.imageVersion, "imageVersionMatches");
    assertEquals(template.osDescription, "osDescriptionMatches");
    assertEquals(template.osFamily, OsFamily.CENTOS);
    assertEquals(template.imageId, null);

    template.imageId("myid");
    assertEquals(template.osArch, null);
    assertEquals(template.imageDescription, null);
    assertEquals(template.imageName, null);
    assertEquals(template.imageVersion, null);
    assertEquals(template.osDescription, null);
    assertEquals(template.osFamily, null);
    assertEquals(template.imageId, "myid");

    verify(defaultLocation);
    verify(optionsProvider);
    verify(templateBuilderProvider);
  }