@Test public void packagingShouldBeJarWhenModelIsNull() { when(fluentComponent.attributes(NAME)).thenReturn(aNestedAttributesMap()); MavenAttributesHelper.setPomAttributes(fluentComponent, model); verify(fluentComponent).withAttribute(eq(NAME), attributesValueCaptor.capture()); Map<String, String> map = attributesValueCaptor.getValue(); assertThat(map, hasEntry(P_PACKAGING, "jar")); }
static void setPomAttributes(final FluentComponent component, final Model model) { Map<String, Object> pomAttributes = new HashMap<>(component.attributes(NAME).backing()); pomAttributes.put(P_PACKAGING, getPackaging(model)); ofNullable(model.getName()).ifPresent(name -> pomAttributes.put(P_POM_NAME, name)); ofNullable(model.getDescription()).ifPresent(desc -> pomAttributes.put(P_POM_DESCRIPTION, desc)); component.withAttribute(NAME, pomAttributes); }
MavenAttributesHelper { static void setPomAttributes(final FluentComponent component, final Model model) { Map<String, Object> pomAttributes = new HashMap<>(component.attributes(NAME).backing()); pomAttributes.put(P_PACKAGING, getPackaging(model)); ofNullable(model.getName()).ifPresent(name -> pomAttributes.put(P_POM_NAME, name)); ofNullable(model.getDescription()).ifPresent(desc -> pomAttributes.put(P_POM_DESCRIPTION, desc)); component.withAttribute(NAME, pomAttributes); } }
MavenAttributesHelper { static void setPomAttributes(final FluentComponent component, final Model model) { Map<String, Object> pomAttributes = new HashMap<>(component.attributes(NAME).backing()); pomAttributes.put(P_PACKAGING, getPackaging(model)); ofNullable(model.getName()).ifPresent(name -> pomAttributes.put(P_POM_NAME, name)); ofNullable(model.getDescription()).ifPresent(desc -> pomAttributes.put(P_POM_DESCRIPTION, desc)); component.withAttribute(NAME, pomAttributes); } private  MavenAttributesHelper(); }
MavenAttributesHelper { static void setPomAttributes(final FluentComponent component, final Model model) { Map<String, Object> pomAttributes = new HashMap<>(component.attributes(NAME).backing()); pomAttributes.put(P_PACKAGING, getPackaging(model)); ofNullable(model.getName()).ifPresent(name -> pomAttributes.put(P_POM_NAME, name)); ofNullable(model.getDescription()).ifPresent(desc -> pomAttributes.put(P_POM_DESCRIPTION, desc)); component.withAttribute(NAME, pomAttributes); } private  MavenAttributesHelper();  }
MavenAttributesHelper { static void setPomAttributes(final FluentComponent component, final Model model) { Map<String, Object> pomAttributes = new HashMap<>(component.attributes(NAME).backing()); pomAttributes.put(P_PACKAGING, getPackaging(model)); ofNullable(model.getName()).ifPresent(name -> pomAttributes.put(P_POM_NAME, name)); ofNullable(model.getDescription()).ifPresent(desc -> pomAttributes.put(P_POM_DESCRIPTION, desc)); component.withAttribute(NAME, pomAttributes); } private  MavenAttributesHelper();   }