Annie Leonard hit the nail on the head. I am just as obsessed with my stuff. I doubt I'll get over the obsession soon enough. Who ever thought about the whole process that goes in making a product, we're just so hung up on the end product. The documentary was quite an eye opener. Where does our stuff come from and where does it go? The system that looks fine is the very system in crisis. Sadly, the latter doesn't meet the eye.
Leonard speaks about a linear system in a finite planet. As a lay person, I would never dig into it. However it is this system that impinges our planet. The whole process isn't mere documentation in black and white, it is based on synergies. It includes environments, economies and yes, PEOPLE. No doubt there are restrictions to the same to avoid unsought issues. But in this perfectly working process there are many hidden facets too. One striking aspect was that of the Government and the Corporations ruling over the economies; corporations enjoying the upper hand. Lately, the Government is so intrigued in attending to the demands of the Corporations that they overlook the common man.
Extraction, which is a vital phase of this process in simpler words, is the wrenching of our planet. None of us realise this hard reality because we are in complete awe of the end product. To get this one flashy product, we are exhausting a huge amount of our natural resources. Going along these lines, where are we heading? Living beyond ones means seems to be a phrase personified in OUR story of stuff.
The ultimate purpose of this system is CONSUMPTION. I consume too, but then again I dump those same products even before a season can pass. I consider myself to be TRENDY, but it turns out that I'm just another fool who falls for the tricks of these business minded people. The trap is such that we buy, dump and buy again and this cycle goes on. My idea of being smart and trendy, actually speaking is polluting the Earth on a larger scale.
I'm not sure if I will ever be able to make a change in the real world but "The Story Of Stuff" has enlightened MY world. I dug deeper into Leonard's website, just out of curiosity. The story of cosmetics and bottled water, they're pretty shocking too. It's strange that despite the fact that we use these products on a regular basis, we know nothing about their origin.
In the bargain of making a lot of money, not only are we killing Mother Earth but ourselves too. It is a sad fact, but it is the very same reality that I am part of. If not anything else, it's pricked my conscience.
I'm not anti consumerism. But it shouldn't be over done, so I've learnt.
RUINOUS – Mother earth or us?


text:
package io.cdap.pipeline.sql.plugins.aggregator;

import io.cdap.pipeline.sql.api.template.QueryContext;
import org.apache.calcite.rel.RelNode;
import org.apache.calcite.tools.RelBuilder;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.Mockito;

import java.util.ArrayList;
import java.util.List;

public class GroupByAggregatorTest {
  @Test
  public void testEmptyAggregates() {
    GroupByConfig config = new GroupByConfig("a", "");
    Assert.assertEquals(0, config.getAggregates().size());
  }

  @Test
  public void testEmptyGroupByFields() {
    GroupByConfig config = new GroupByConfig("", "a:COUNT(b)");
    Assert.assertEquals(0, config.getGroupByFields().size());
  }

  @Test(expected = IllegalArgumentException.class)
  public void testInvalidGroupByField() {
    GroupByConfig config = new GroupByConfig(",", "a:COUNT(b)");
    config.getGroupByFields();
  }

  @Test(expected = IllegalArgumentException.class)
  public void testNoAliasAggregate() {
    GroupByConfig config = new GroupByConfig("", ":COUNT(b)");
    config.getAggregates();
  }

  @Test(expected = IllegalArgumentException.class)
  public void testNoFieldAggregate() {
    GroupByConfig config = new GroupByConfig("", "a:COUNT()");
    config.getAggregates();
  }

  @Test(expected = IllegalArgumentException.class)
  public void testImproperFormatAggregate() {
    GroupByConfig config = new GroupByConfig("", "a:COUNT(a");
    config.getAggregates();
  }

  @Test(expected = IllegalArgumentException.class)
  public void testInvalidAggregatesFieldFunction() {
    GroupByConfig config = new GroupByConfig("", "a:invalid(b)");
    GroupByAggregator aggregator = new GroupByAggregator(config);
    RelBuilder builder = Mockito.mock(RelBuilder.class);
    QueryContext context = new QueryContext(builder, null);
    aggregator.getQuery(context);
  }

  @Test
  public void testValidCountStar() {
    GroupByConfig config = new GroupByConfig("", "d:COUNT(*)");
    GroupByAggregator aggregator = new GroupByAggregator(config);

    RelBuilder builder = Mockito.mock(RelBuilder.class);
    RelBuilder.AggCall aggCall = Mockito.mock(RelBuilder.AggCall.class);
    RelBuilder finalBuilder = Mockito.mock(RelBuilder.class);
    RelNode expected = Mockito.mock(RelNode.class);

    Mockito.when(builder.countStar("d")).thenReturn(aggCall);
    List<RelBuilder.AggCall> aggCalls = new ArrayList<>();
    aggCalls.add(aggCall);
    Mockito.when(builder.aggregate(null, aggCalls)).thenReturn(finalBuilder);
    Mockito.when(finalBuilder.build()).thenReturn(expected);

    QueryContext context = new QueryContext(builder, null);
    RelNode rel = aggregator.getQuery(context);
    Assert.assertEquals(expected, rel);
  }
}

redpajama_set_name: RedPajamaGithub